EnumValue::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 12
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 4
c 1
b 0
f 0
nc 4
nop 4
dl 0
loc 12
ccs 5
cts 5
cp 1
crap 3
rs 10
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
The property description is declared read-only in Andi\GraphQL\Field\EnumValue.
Loading history...
22
        }
23
24 2
        if (null !== $deprecationReason) {
25 1
            $this->deprecationReason = $deprecationReason;
0 ignored issues
show
Bug introduced by
The property deprecationReason is declared read-only in Andi\GraphQL\Field\EnumValue.
Loading history...
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