AbstractArgument   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 39
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 39
ccs 11
cts 13
cp 0.8462
rs 10
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A getName() 0 3 1
A hasDefaultValue() 0 3 1
A getType() 0 3 1
A getDescription() 0 4 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
        /** @psalm-suppress RedundantPropertyInitializationCheck */
33 1
        return $this->description ?? null;
34
    }
35
36 1
    public function getType(): string
37
    {
38 1
        return $this->type;
39
    }
40
41 1
    public function getMode(): int
42
    {
43 1
        return $this->mode;
44
    }
45
46
    public function hasDefaultValue(): bool
47
    {
48
        return $this instanceof DefaultValueAwareInterface;
49
    }
50
}
51