ILIAS  release_8 Revision v8.24
class.ilCronJobResult.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
24 public const STATUS_NO_ACTION = 2;
25 public const STATUS_OK = 3;
26 public const STATUS_CRASHED = 4;
27 public const STATUS_RESET = 5;
28 public const STATUS_FAIL = 6;
29
30 public const CODE_NO_RESULT = 'job_no_result';
31 public const CODE_MANUAL_RESET = 'job_manual_reset';
32 public const CODE_SUPPOSED_CRASH = 'job_auto_deactivation_time_limit';
33
35 protected string $message = '';
36 protected ?string $code = null;
37 protected string $duration = '0';
38
42 public static function getCoreCodes(): array
43 {
44 return [
48 ];
49 }
50
51 public function getStatus(): int
52 {
53 return $this->status;
54 }
55
56 public function setStatus(int $a_value): void
57 {
58 if (!in_array($a_value, $this->getValidStatus(), true)) {
59 throw new InvalidArgumentException(sprintf(
60 'The passed status "%s" is not valid, must be of one of: %s',
61 $a_value,
62 implode(', ', $this->getValidStatus())
63 ));
64 }
65
66 $this->status = $a_value;
67 }
68
72 protected function getValidStatus(): array
73 {
74 return [
81 ];
82 }
83
84 public function getMessage(): string
85 {
86 return $this->message;
87 }
88
89 public function setMessage(string $value): void
90 {
91 $value = trim($value);
92 if (ilStr::strLen($value) > 400) {
93 throw new InvalidArgumentException("The message must not exceed 400 characters");
94 }
95
96 $this->message = $value;
97 }
98
99 public function getCode(): ?string
100 {
101 return $this->code;
102 }
103
104 public function setCode(string $a_value): void
105 {
106 if (!in_array($a_value, self::getCoreCodes(), true)) {
107 throw new InvalidArgumentException(sprintf(
108 'The passed code "%s" is not valid, must be of one of: %s',
109 $a_value,
110 implode(', ', self::getCoreCodes())
111 ));
112 }
113
114 $this->code = $a_value;
115 }
116
117 public function getDuration(): float
118 {
119 return (float) $this->duration;
120 }
121
122 public function setDuration(float $a_value): void
123 {
124 $this->duration = number_format($a_value, 3, '.', '');
125 }
126}
setDuration(float $a_value)
setMessage(string $value)
setCode(string $a_value)
static strLen(string $a_string)
Definition: class.ilStr.php:63