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

ExportTransactionLines::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1.037

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 15
ccs 6
cts 9
cp 0.6667
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1.037
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Api\Field\Mutation;
6
7
use Application\Api\Field\Standard;
8
use Application\Model\TransactionLine;
9
use Application\Service\Exporter\TransactionLines;
10
use Ecodev\Felix\Api\Field\FieldInterface;
11
use GraphQL\Type\Definition\Type;
12
use Mezzio\Session\SessionInterface;
13
14
abstract class ExportTransactionLines implements FieldInterface
15
{
16 1
    public static function build(): iterable
17
    {
18 1
        yield 'exportTransactionLines' => fn () => [
19 1
            'type' => Type::nonNull(Type::string()),
20 1
            'description' => 'Prepare an export of transactionLines and return the URL to download it',
21 1
            'args' => Standard::getListArguments(TransactionLine::class, false),
22 1
            'resolve' => function ($root, array $args, SessionInterface $session): string {
23
                global $container;
24
25
                /** @var TransactionLines $exporter */
26
                $exporter = $container->get(TransactionLines::class);
27
28
                $qb = Standard::createFilteredQueryBuilder(TransactionLine::class, $args);
29
30
                return $exporter->export($qb->getQuery()->getResult());
0 ignored issues
show
Bug introduced by
It seems like $qb->getQuery()->getResult() can also be of type integer; however, parameter $items of Application\Service\Expo...tractExporter::export() does only seem to accept iterable, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

30
                return $exporter->export(/** @scrutinizer ignore-type */ $qb->getQuery()->getResult());
Loading history...
31 1
            },
32 1
        ];
33
    }
34
}
35