Total Complexity | 6 |
Total Lines | 77 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | class Status |
||
16 | { |
||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | private $id; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | private $status; |
||
26 | |||
27 | /** |
||
28 | * @var string|null |
||
29 | */ |
||
30 | private $optionalReference; |
||
31 | |||
32 | /** |
||
33 | * @var array|null |
||
34 | */ |
||
35 | private $context; |
||
36 | |||
37 | public function __construct(string $id, string $status = 'OK', ?string $optionalReference = null, ?array $context = null) |
||
38 | { |
||
39 | $this->id = $id; |
||
40 | $this->status = $status; |
||
41 | $this->optionalReference = $optionalReference; |
||
42 | $this->context = $context; |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @return string |
||
47 | */ |
||
48 | public function getId(): string |
||
49 | { |
||
50 | return $this->id; |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * Returns some status string. The string 'OK' assumes no error was there. |
||
55 | * |
||
56 | * @return string |
||
57 | */ |
||
58 | public function getStatus(): string |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * Return some reference to some arbitrary URL. Useful to link people to a maintenance page with information |
||
65 | * how long it takes before it's operational again. |
||
66 | * |
||
67 | * @return string|null |
||
68 | */ |
||
69 | public function getOptionalReference(): ?string |
||
70 | { |
||
71 | return $this->optionalReference; |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * Returns an array with arbitrary data. Can be anything.... |
||
76 | * |
||
77 | * @return array|null |
||
78 | */ |
||
79 | public function getContext(): ?array |
||
80 | { |
||
81 | return $this->context; |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * Returns true to tell the status check is 'healthy'. |
||
86 | * |
||
87 | * @return bool |
||
88 | */ |
||
89 | public function hasNoErrors(): bool |
||
92 | } |
||
93 | } |
||
94 |