AbstractArgument::getDescription()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
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
        /** @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