Passed
Push — master ( 383648...c60c96 )
by Andrey
50s queued 13s
created

AbstractInputObjectField::getMode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Andi\GraphQL\Field;
6
7
use Andi\GraphQL\Definition\Field\DefaultValueAwareInterface;
8
use Andi\GraphQL\Definition\Field\DeprecationReasonAwareInterface;
9
use Andi\GraphQL\Definition\Field\InputObjectFieldInterface;
10
11
abstract class AbstractInputObjectField implements InputObjectFieldInterface, DeprecationReasonAwareInterface
12
{
13
    private readonly string $description;
14
15
    private readonly string $deprecationReason;
16
17
    public function __construct(
18
        private readonly string $name,
19
        private readonly string $type,
20
        private readonly int $mode = 0,
21
        ?string $description = null,
22
        ?string $deprecationReason = null,
23
    ) {
24
        if (null !== $description) {
25
            $this->description = $description;
0 ignored issues
show
Bug introduced by
The property description is declared read-only in Andi\GraphQL\Field\AbstractInputObjectField.
Loading history...
26
        }
27
28
        if (null !== $deprecationReason) {
29
            $this->deprecationReason = $deprecationReason;
0 ignored issues
show
Bug introduced by
The property deprecationReason is declared read-only in Andi\GraphQL\Field\AbstractInputObjectField.
Loading history...
30
        }
31
    }
32
33
    public function getName(): string
34
    {
35
        return $this->name;
36
    }
37
38
    public function getDescription(): ?string
39
    {
40
        return $this->description ?? null;
41
    }
42
43
    public function getType(): string
44
    {
45
        return $this->type;
46
    }
47
48
    public function getMode(): int
49
    {
50
        return $this->mode;
51
    }
52
53
    public function getDeprecationReason(): ?string
54
    {
55
        return $this->deprecationReason ?? null;
56
    }
57
58
    public function hasDefaultValue(): bool
59
    {
60
        return $this instanceof DefaultValueAwareInterface;
61
    }
62
}
63