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

ExportTransactionLines   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 62.5%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 11
dl 0
loc 18
ccs 5
cts 8
cp 0.625
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 16 1
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(): array
17
    {
18
        return [
19 1
            'name' => 'exportTransactionLines',
20 1
            'type' => Type::nonNull(Type::string()),
21
            'description' => 'Prepare an export of transactionLines and return the URL to download it',
22 1
            'args' => Standard::getListArguments(TransactionLine::class, false),
23 1
            'resolve' => function ($root, array $args, SessionInterface $session): string {
24
                global $container;
25
26
                /** @var TransactionLines $exporter */
27
                $exporter = $container->get(TransactionLines::class);
28
29
                $qb = Standard::createFilteredQueryBuilder(TransactionLine::class, $args);
30
31
                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 array, 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

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