1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Andi\GraphQL\Field; |
||
6 | |||
7 | use Andi\GraphQL\Definition\Field\EnumValueInterface; |
||
8 | |||
9 | final class EnumValue implements EnumValueInterface |
||
10 | { |
||
11 | private readonly string $description; |
||
12 | private readonly string $deprecationReason; |
||
13 | |||
14 | 2 | public function __construct( |
|
15 | private readonly string $name, |
||
16 | private readonly mixed $value, |
||
17 | ?string $description = null, |
||
18 | ?string $deprecationReason = null, |
||
19 | ) { |
||
20 | 2 | if (null !== $description) { |
|
21 | 1 | $this->description = $description; |
|
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
22 | } |
||
23 | |||
24 | 2 | if (null !== $deprecationReason) { |
|
25 | 1 | $this->deprecationReason = $deprecationReason; |
|
0 ignored issues
–
show
|
|||
26 | } |
||
27 | } |
||
28 | |||
29 | |||
30 | 2 | public function getName(): string |
|
31 | { |
||
32 | 2 | return $this->name; |
|
33 | } |
||
34 | |||
35 | 2 | public function getDescription(): ?string |
|
36 | { |
||
37 | /** @psalm-suppress RedundantPropertyInitializationCheck */ |
||
38 | 2 | return $this->description ?? null; |
|
39 | } |
||
40 | |||
41 | 2 | public function getDeprecationReason(): ?string |
|
42 | { |
||
43 | /** @psalm-suppress RedundantPropertyInitializationCheck */ |
||
44 | 2 | return $this->deprecationReason ?? null; |
|
45 | } |
||
46 | |||
47 | 2 | public function getValue(): mixed |
|
48 | { |
||
49 | 2 | return $this->value; |
|
50 | } |
||
51 | } |
||
52 |