Failed Conditions
Push — master ( 044ed2...482608 )
by Adrien
03:59
created

NextAccountCode   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
wmc 1
eloc 8
dl 0
loc 13
ccs 6
cts 8
cp 0.75
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 11 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(): iterable
15
    {
16 1
        yield 'nextAccountCode' => fn () => [
17 1
            'type' => Type::nonNull(Type::int()),
18 1
            'description' => 'Next available account code for creation',
19 1
            'args' => [],
20 1
            'resolve' => function ($root, array $args): int {
21
                /** @var AccountRepository $repository */
22
                $repository = _em()->getRepository(Account::class);
23
24
                return $repository->getNextCodeAvailable();
25 1
            },
26 1
        ];
27
    }
28
}
29