andrey-mokhov /
graphql-php
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Andi\GraphQL\Field; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * @internal |
||
| 9 | * @psalm-internal Andi\GraphQL |
||
| 10 | */ |
||
| 11 | abstract class AbstractAnonymousObjectField extends AbstractObjectField |
||
| 12 | { |
||
| 13 | protected readonly mixed $resolveFn; |
||
| 14 | protected readonly mixed $complexityFn; |
||
| 15 | |||
| 16 | 14 | public function __construct( |
|
| 17 | string $name, |
||
| 18 | array $field, |
||
| 19 | ?callable $resolve = null, |
||
| 20 | ?callable $complexity = null, |
||
| 21 | ) { |
||
| 22 | 14 | $this->name = $name; |
|
| 23 | 14 | $this->type = $field['type']; |
|
| 24 | 14 | $this->mode = $field['mode'] ?? 0; |
|
| 25 | |||
| 26 | 14 | if (isset($field['description']) && \is_string($field['description'])) { |
|
| 27 | 1 | $this->description = $field['description']; |
|
| 28 | } |
||
| 29 | |||
| 30 | 14 | if (isset($field['deprecationReason']) && \is_string($field['deprecationReason'])) { |
|
| 31 | 1 | $this->deprecationReason = $field['deprecationReason']; |
|
| 32 | } |
||
| 33 | |||
| 34 | 14 | if (isset($field['arguments']) && \is_iterable($field['arguments'])) { |
|
| 35 | 1 | $this->arguments = $field['arguments']; |
|
| 36 | } |
||
| 37 | |||
| 38 | 14 | if (null !== $resolve) { |
|
| 39 | 8 | $this->resolveFn = $resolve; |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 40 | } |
||
| 41 | |||
| 42 | 14 | if (null !== $complexity) { |
|
| 43 | 8 | $this->complexityFn = $complexity; |
|
|
0 ignored issues
–
show
|
|||
| 44 | } |
||
| 45 | } |
||
| 46 | } |
||
| 47 |