Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| FromMetadataInputType | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | namespace Apie\Graphql\Types; |
| 3 | |
| 4 | use Apie\Core\Metadata\MetadataInterface; |
| 5 | use Apie\Graphql\Concerns\CreatesFromMeta; |
| 6 | use GraphQL\Type\Definition\InputObjectType; |
| 7 | |
| 8 | class FromMetadataInputType extends InputObjectType |
| 9 | { |
| 10 | use CreatesFromMeta; |
| 11 | |
| 12 | public function __construct(MetadataInterface $metadata, string $suffix = '') |
| 13 | { |
| 14 | $config = [ |
| 15 | 'name' => ($metadata->toClass()?->getShortName() ?? $metadata->toScalarType()->value) . $suffix, |
| 16 | 'fields' => [ |
| 17 | ], |
| 18 | ]; |
| 19 | foreach ($metadata->getHashmap() as $name => $field) { |
| 20 | if ($field->isField()) { |
| 21 | $config['fields'][$name] = [ |
| 22 | 'type' => self::createFromField($field), |
| 23 | ]; |
| 24 | } |
| 25 | } |
| 26 | parent::__construct($config); |
| 27 | } |
| 28 | |
| 29 | |
| 30 | } |