Failed Conditions
Push — develop ( afa323...bcac9d )
by Sam
04:23
created

CardDomains::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 15
ccs 13
cts 13
cp 1
rs 9.9666
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Api\Field\Query;
6
7
use Application\Model\Card;
8
use Application\Model\Domain;
9
use Ecodev\Felix\Api\Field\FieldInterface;
10
use GraphQL\Type\Definition\Type;
11
12
abstract class CardDomains implements FieldInterface
13
{
14 1
    public static function build(): iterable
15
    {
16 1
        yield 'cardDomains' => fn () => [
17 1
            'type' => Type::nonNull(Type::listOf(Type::nonNull(_types()->getOutput(Domain::class)))),
18 1
            'args' => [
19 1
                [
20 1
                    'name' => 'filter',
21 1
                    'type' => _types()->getFilter(Card::class),
22 1
                ],
23 1
            ],
24 1
            'description' => 'List domains sorted by usage on cards filtered by given variables',
25 1
            'resolve' => function ($root, array $args): array {
26 1
                $qb = _types()->createFilteredQueryBuilder(Card::class, $args['filter'], []);
27
28 1
                return _em()->getRepository(Domain::class)->getByCards($qb);
29 1
            },
30 1
        ];
31
    }
32
}
33