1 | <?php |
||
18 | class Message implements JsonSerializable |
||
19 | { |
||
20 | public const SEVERITY_LOW = 'low'; |
||
21 | |||
22 | public const SEVERITY_MEDIUM = 'medium'; |
||
23 | |||
24 | public const SEVERITY_HIGH = 'high'; |
||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | private $message; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | private $severity; |
||
34 | |||
35 | /** |
||
36 | * Message constructor. |
||
37 | */ |
||
38 | private function __construct(string $message, string $severity) |
||
43 | |||
44 | /** |
||
45 | * Creates a message with severity=low. |
||
46 | * |
||
47 | * @return Message |
||
48 | */ |
||
49 | public static function low(string $message): self |
||
53 | |||
54 | /** |
||
55 | * Creates a message with severity=medium. |
||
56 | * |
||
57 | * @return Message |
||
58 | */ |
||
59 | public static function medium(string $message): self |
||
63 | |||
64 | /** |
||
65 | * Creates a message with severity=high. |
||
66 | * |
||
67 | * @return Message |
||
68 | */ |
||
69 | public static function high(string $message): self |
||
73 | |||
74 | /** |
||
75 | * Returns the message. |
||
76 | */ |
||
77 | public function getMessage(): string |
||
81 | |||
82 | /** |
||
83 | * Returns the severity of the message. |
||
84 | */ |
||
85 | public function getSeverity(): string |
||
89 | |||
90 | public function jsonSerialize(): array |
||
97 | } |
||
98 |