Passed
Pull Request — master (#38)
by Andrey
03:26
created

InputObjectField::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 6
dl 0
loc 12
ccs 4
cts 4
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Andi\GraphQL\Attribute;
6
7
use Attribute;
8
use ReflectionProperty;
9
use Spiral\Attributes\NamedArgumentConstructor;
10
11
#[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_PROPERTY), NamedArgumentConstructor]
12
final class InputObjectField extends AbstractField
13
{
14
    public readonly mixed $defaultValue;
15
16 3
    public function __construct(
17
        ?string $name = null,
18
        ?string $description = null,
19
        ?string $type = null,
20
        ?int $mode = null,
21
        ?string $deprecationReason = null,
22
        mixed $defaultValue = null,
23
    ) {
24 3
        parent::__construct($name, $description, $type, $mode, $deprecationReason);
25
26 3
        if (func_num_args() >= 6) {
27 2
            $this->defaultValue = $defaultValue;
0 ignored issues
show
Bug introduced by
The property defaultValue is declared read-only in Andi\GraphQL\Attribute\InputObjectField.
Loading history...
28
        }
29
    }
30
31 3
    public function hasDefaultValue(): bool
32
    {
33 3
        return (new ReflectionProperty($this, 'defaultValue'))->isInitialized($this);
34
    }
35
}
36