Passed
Push — master ( 898411...5b804b )
by Andrey
56s queued 13s
created

AbstractInputObjectField::hasDefaultValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
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 7
    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 7
        if (null !== $description) {
25 3
            $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 7
        if (null !== $deprecationReason) {
29 3
            $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 8
    public function getName(): string
34
    {
35 8
        return $this->name;
36
    }
37
38 8
    public function getDescription(): ?string
39
    {
40 8
        return $this->description ?? null;
41
    }
42
43 8
    public function getType(): string
44
    {
45 8
        return $this->type;
46
    }
47
48 8
    public function getMode(): int
49
    {
50 8
        return $this->mode;
51
    }
52
53 8
    public function getDeprecationReason(): ?string
54
    {
55 8
        return $this->deprecationReason ?? null;
56
    }
57
58 2
    public function hasDefaultValue(): bool
59
    {
60 2
        return $this instanceof DefaultValueAwareInterface;
61
    }
62
}
63