CollectionCopyrights::build()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1.0202

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 15
ccs 8
cts 11
cp 0.7272
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1.0202
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\Collection;
9
use Application\Repository\CollectionRepository;
10
use Ecodev\Felix\Api\Field\FieldInterface;
11
use GraphQL\Type\Definition\Type;
12
13
abstract class CollectionCopyrights implements FieldInterface
14
{
15 1
    public static function build(): iterable
16
    {
17 1
        yield 'collectionCopyrights' => fn () => [
18 1
            'type' => Type::nonNull(Type::string()),
19 1
            'description' => 'Returns the copyrights of given card',
20 1
            'args' => [
21 1
                'card' => Type::nonNull(_types()->getId(Card::class)),
22 1
            ],
23 1
            'resolve' => function ($root, array $args): string {
24
                $card = $args['card']->getEntity();
25
26
                /** @var CollectionRepository $collectionRepository */
27
                $collectionRepository = _em()->getRepository(Collection::class);
28
29
                return $collectionRepository->getCopyrights($card);
30 1
            },
31 1
        ];
32
    }
33
}
34