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; |
|
|
|
|
26
|
|
|
} |
27
|
|
|
|
28
|
7 |
|
if (null !== $deprecationReason) { |
29
|
3 |
|
$this->deprecationReason = $deprecationReason; |
|
|
|
|
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
|
8 |
|
return $this->description ?? null; |
41
|
|
|
} |
42
|
|
|
|
43
|
8 |
|
public function getType(): string |
44
|
|
|
{ |
45
|
8 |
|
return $this->type; |
46
|
|
|
} |
47
|
|
|
|
48
|
8 |
|
public function getMode(): int |
49
|
|
|
{ |
50
|
8 |
|
return $this->mode; |
51
|
|
|
} |
52
|
|
|
|
53
|
8 |
|
public function getDeprecationReason(): ?string |
54
|
|
|
{ |
55
|
8 |
|
return $this->deprecationReason ?? null; |
56
|
|
|
} |
57
|
|
|
|
58
|
2 |
|
public function hasDefaultValue(): bool |
59
|
|
|
{ |
60
|
2 |
|
return $this instanceof DefaultValueAwareInterface; |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|