Failed Conditions
Push — master ( 27554e...857869 )
by Luca
09:08
created

CollectionCopyrights::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1.0122

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 17
ccs 10
cts 13
cp 0.7692
rs 9.9332
cc 1
nc 1
nop 0
crap 1.0122
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(): array
16
    {
17 1
        return
18 1
            [
19 1
                'name' => 'collectionCopyrights',
20 1
                'type' => Type::nonNull(Type::string()),
21 1
                'description' => 'Returns the copyrights of given card',
22 1
                'args' => [
23 1
                    'card' => Type::nonNull(_types()->getId(Card::class)),
24 1
                ],
25 1
                'resolve' => function (array $root, array $args): string {
26
                    $card = $args['card']->getEntity();
27
28
                    /** @var CollectionRepository $collectionRepository */
29
                    $collectionRepository = _em()->getRepository(Collection::class);
30
31
                    return $collectionRepository->getCopyrights($card);
32 1
                },
33 1
            ];
34
    }
35
}
36