Argument::__construct()   A
last analyzed

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 1
Metric Value
cc 2
eloc 3
c 1
b 0
f 1
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 Spiral\Attributes\NamedArgumentConstructor;
9
10
#[Attribute(Attribute::TARGET_PARAMETER), NamedArgumentConstructor]
11
final class Argument extends AbstractDefinition
12
{
13
    public readonly mixed $defaultValue;
14
15 3
    public function __construct(
16
        ?string $name = null,
17
        ?string $description = null,
18
        public readonly ?string $type = null,
19
        public readonly ?int $mode = null,
20
        public readonly ?string $deprecationReason = null,
21
        mixed $defaultValue = null,
22
    ) {
23 3
        parent::__construct($name, $description);
24
25 3
        if (\func_num_args() >= 6) {
26 2
            $this->defaultValue = $defaultValue;
0 ignored issues
show
Bug introduced by
The property defaultValue is declared read-only in Andi\GraphQL\Attribute\Argument.
Loading history...
27
        }
28
    }
29
30 3
    public function hasDefaultValue(): bool
31
    {
32 3
        return (new \ReflectionProperty($this, 'defaultValue'))->isInitialized($this);
33
    }
34
}
35