Passed
Push — master ( 383648...c60c96 )
by Andrey
50s queued 13s
created

AbstractArgument::getMode()   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 0
Metric Value
cc 1
eloc 1
c 0
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\Argument;
6
7
use Andi\GraphQL\Definition\Field\ArgumentInterface;
8
use Andi\GraphQL\Definition\Field\DefaultValueAwareInterface;
9
10
abstract class AbstractArgument implements ArgumentInterface
11
{
12
    private readonly string $description;
13
14 1
    public function __construct(
15
        private readonly string $name,
16
        private readonly string $type,
17
        private readonly int $mode = 0,
18
        ?string $description = null,
19
    ) {
20 1
        if (null !== $description) {
21 1
            $this->description = $description;
0 ignored issues
show
Bug introduced by
The property description is declared read-only in Andi\GraphQL\Argument\AbstractArgument.
Loading history...
22
        }
23
    }
24
25 1
    public function getName(): string
26
    {
27 1
        return $this->name;
28
    }
29
30 1
    public function getDescription(): ?string
31
    {
32 1
        return $this->description ?? null;
33
    }
34
35 1
    public function getType(): string
36
    {
37 1
        return $this->type;
38
    }
39
40 1
    public function getMode(): int
41
    {
42 1
        return $this->mode ?? 0;
43
    }
44
45
    public function hasDefaultValue(): bool
46
    {
47
        return $this instanceof DefaultValueAwareInterface;
48
    }
49
}
50