Debian Codegraph @

lib/3rdParty/composer/web-token/jwt-library/KeyManagement/Analyzer/Message.php

raw symbols SCIP
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 * Creates a message with severity=low.
25 */
26 public static function low(string $message): self
27 {
28 return new self($message, self::SEVERITY_LOW);
29 }
30
31 /**
32 * Creates a message with severity=medium.
33 */
34 public static function medium(string $message): self
35 {
36 return new self($message, self::SEVERITY_MEDIUM);
37 }
38
39 /**
40 * Creates a message with severity=high.
41 */
42 public static function high(string $message): self
43 {
44 return new self($message, self::SEVERITY_HIGH);
45 }
46
47 /**
48 * Returns the message.
49 */
50 public function getMessage(): string
51 {
52 return $this->message;
53 }
54
55 /**
56 * Returns the severity of the message.
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 }