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

AbstractInputObjectField   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 50
ccs 17
cts 17
cp 1
rs 10
wmc 9

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A getType() 0 3 1
A hasDefaultValue() 0 3 1
A getDescription() 0 3 1
A getMode() 0 3 1
A __construct() 0 13 3
A getDeprecationReason() 0 3 1
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