Passed
Push — master ( 3ba489...3505e6 )
by Adrien
11:36
created

NextAccountCode   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 71.43%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 15
ccs 5
cts 7
cp 0.7143
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 13 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Api\Field\Query;
6
7
use Application\Model\Account;
8
use Application\Repository\AccountRepository;
9
use Ecodev\Felix\Api\Field\FieldInterface;
10
use GraphQL\Type\Definition\Type;
11
12
abstract class NextAccountCode implements FieldInterface
13
{
14 1
    public static function build(): array
15
    {
16
        return
17
            [
18 1
                'name' => 'nextAccountCode',
19 1
                'type' => Type::nonNull(Type::int()),
20 1
                'description' => 'Next available account code for creation',
21
                'args' => [],
22 1
                'resolve' => function ($root, array $args): int {
23
                    /** @var AccountRepository $repository */
24
                    $repository = _em()->getRepository(Account::class);
25
26
                    return $repository->getNextCodeAvailable();
27 1
                },
28
            ];
29
    }
30
}
31