Passed
Push — master ( f8361b...5ed10a )
by Adrien
07:04
created

NextAccountCode   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 1
eloc 9
dl 0
loc 15
ccs 4
cts 6
cp 0.6667
rs 10
c 0
b 0
f 0

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
                '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
                },
28
            ];
29
    }
30
}
31