Failed Conditions
Push — master ( d2dc84...8e498d )
by Adrien
07:27
created

ExportTransactionLines::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1.037

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 16
ccs 6
cts 9
cp 0.6667
rs 9.9332
c 1
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(): array
17
    {
18
        return [
19 1
            'name' => 'exportTransactionLines',
20 1
            'type' => Type::nonNull(Type::string()),
21 1
            '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());
32 1
            },
33
        ];
34
    }
35
}
36