andrey-mokhov /
graphql-php
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Andi\GraphQL\Field; |
||
| 6 | |||
| 7 | use Andi\GraphQL\Definition\Field\DefaultValueAwareInterface; |
||
| 8 | |||
| 9 | final class InputObjectField extends AbstractInputObjectField implements DefaultValueAwareInterface |
||
| 10 | { |
||
| 11 | private readonly mixed $defaultValue; |
||
| 12 | |||
| 13 | 5 | public function __construct( |
|
| 14 | string $name, |
||
| 15 | string $type, |
||
| 16 | int $mode = 0, |
||
| 17 | ?string $description = null, |
||
| 18 | ?string $deprecationReason = null, |
||
| 19 | mixed $defaultValue = null, |
||
| 20 | ) { |
||
| 21 | 5 | parent::__construct($name, $type, $mode, $description, $deprecationReason); |
|
| 22 | |||
| 23 | 5 | if (\func_num_args() >= 6) { |
|
| 24 | 1 | $this->defaultValue = $defaultValue; |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 25 | } |
||
| 26 | } |
||
| 27 | |||
| 28 | 6 | public function hasDefaultValue(): bool |
|
| 29 | { |
||
| 30 | 6 | return isset($this->defaultValue) |
|
| 31 | 6 | || (new \ReflectionProperty($this, 'defaultValue'))->isInitialized($this); |
|
| 32 | } |
||
| 33 | |||
| 34 | 1 | public function getDefaultValue(): mixed |
|
| 35 | { |
||
| 36 | 1 | return $this->defaultValue; |
|
| 37 | } |
||
| 38 | } |
||
| 39 |