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

AbstractArgument   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 84.62%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 38
ccs 11
cts 13
cp 0.8462
rs 10
wmc 7

6 Methods

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