Issues (169)

src/Field/AbstractInputObjectField.php (2 issues)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Andi\GraphQL\Field;
6
7
use Andi\GraphQL\Definition\Field\DefaultValueAwareInterface;
8
use Andi\GraphQL\Definition\Field\DeprecationReasonAwareInterface;
9
use Andi\GraphQL\Definition\Field\InputObjectFieldInterface;
10
11
abstract class AbstractInputObjectField implements InputObjectFieldInterface, DeprecationReasonAwareInterface
12
{
13
    private readonly string $description;
14
15
    private readonly string $deprecationReason;
16
17 7
    public function __construct(
18
        private readonly string $name,
19
        private readonly string $type,
20
        private readonly int $mode = 0,
21
        ?string $description = null,
22
        ?string $deprecationReason = null,
23
    ) {
24 7
        if (null !== $description) {
25 3
            $this->description = $description;
0 ignored issues
show
The property description is declared read-only in Andi\GraphQL\Field\AbstractInputObjectField.
Loading history...
26
        }
27
28 7
        if (null !== $deprecationReason) {
29 3
            $this->deprecationReason = $deprecationReason;
0 ignored issues
show
The property deprecationReason is declared read-only in Andi\GraphQL\Field\AbstractInputObjectField.
Loading history...
30
        }
31
    }
32
33 8
    public function getName(): string
34
    {
35 8
        return $this->name;
36
    }
37
38 8
    public function getDescription(): ?string
39
    {
40
        /** @psalm-suppress RedundantPropertyInitializationCheck */
41 8
        return $this->description ?? null;
42
    }
43
44 8
    public function getType(): string
45
    {
46 8
        return $this->type;
47
    }
48
49 8
    public function getMode(): int
50
    {
51 8
        return $this->mode;
52
    }
53
54 8
    public function getDeprecationReason(): ?string
55
    {
56
        /** @psalm-suppress RedundantPropertyInitializationCheck */
57 8
        return $this->deprecationReason ?? null;
58
    }
59
60 2
    public function hasDefaultValue(): bool
61
    {
62 2
        return $this instanceof DefaultValueAwareInterface;
63
    }
64
}
65