| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Jose\Component\KeyManagement\Analyzer; |
| 6 |
|
| 7 |
use JsonSerializable; |
| 8 |
|
| 9 |
class Message implements JsonSerializable |
| 10 |
{ |
| 11 |
final public const SEVERITY_LOW = 'low'; |
| 12 |
|
| 13 |
final public const SEVERITY_MEDIUM = 'medium'; |
| 14 |
|
| 15 |
final public const SEVERITY_HIGH = 'high'; |
| 16 |
|
| 17 |
private function __construct( |
| 18 |
private readonly string $message, |
| 19 |
private readonly string $severity |
| 20 |
) { |
| 21 |
} |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
public static function low(string $message): self |
| 27 |
{ |
| 28 |
return new self($message, self::SEVERITY_LOW); |
| 29 |
} |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
public static function medium(string $message): self |
| 35 |
{ |
| 36 |
return new self($message, self::SEVERITY_MEDIUM); |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
public static function high(string $message): self |
| 43 |
{ |
| 44 |
return new self($message, self::SEVERITY_HIGH); |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
public function getMessage(): string |
| 51 |
{ |
| 52 |
return $this->message; |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
public function getSeverity(): string |
| 59 |
{ |
| 60 |
return $this->severity; |
| 61 |
} |
| 62 |
|
| 63 |
public function jsonSerialize(): array |
| 64 |
{ |
| 65 |
return [ |
| 66 |
'message' => $this->message, |
| 67 |
'severity' => $this->severity, |
| 68 |
]; |
| 69 |
} |
| 70 |
} |