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

InputObjectField   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 28
ccs 9
cts 9
cp 1
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A hasDefaultValue() 0 4 2
A __construct() 0 12 2
A getDefaultValue() 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
9
final class InputObjectField extends AbstractInputObjectField implements DefaultValueAwareInterface
10
{
11
    private readonly mixed $defaultValue;
12
13 5
    public function __construct(
14
        string  $name,
15
        string  $type,
16
        int $mode = 0,
17
        ?string $description = null,
18
        ?string $deprecationReason = null,
19
        mixed $defaultValue = null,
20
    ) {
21 5
        parent::__construct($name, $type, $mode, $description, $deprecationReason);
22
23 5
        if (func_num_args() >= 6) {
24 1
            $this->defaultValue = $defaultValue;
0 ignored issues
show
Bug introduced by
The property defaultValue is declared read-only in Andi\GraphQL\Field\InputObjectField.
Loading history...
25
        }
26
    }
27
28 6
    public function hasDefaultValue(): bool
29
    {
30 6
        return isset($this->defaultValue)
31 6
            || (new \ReflectionProperty($this, 'defaultValue'))->isInitialized($this);
32
    }
33
34 1
    public function getDefaultValue(): mixed
35
    {
36 1
        return $this->defaultValue;
37
    }
38
}
39