Passed
Push — master ( 3ba489...3505e6 )
by Adrien
11:36
created

BankingInfos::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 31
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1.3169

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 24
nc 1
nop 0
dl 0
loc 31
ccs 7
cts 22
cp 0.3182
crap 1.3169
rs 9.536
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Api\Field\Query;
6
7
use Application\Model\User;
8
use Ecodev\Felix\Api\Field\FieldInterface;
9
use Ecodev\Felix\Service\Bvr;
10
use GraphQL\Type\Definition\Type;
11
12
abstract class BankingInfos implements FieldInterface
13
{
14 1
    public static function build(): array
15
    {
16
        return
17
            [
18 1
                'name' => 'bankingInfos',
19 1
                'type' => Type::nonNull(_types()->get('BankingInfos')),
20 1
                'description' => 'Represents currently logged-in user',
21
                'args' => [
22 1
                    'user' => Type::nonNull(_types()->getId(User::class)),
23 1
                    'amount' => _types()->get('Money'),
24
                ],
25 1
                'resolve' => function ($root, array $args): array {
26
                    global $container;
27
                    $config = $container->get('config')['banking'];
28
                    $bankAccount = $config['bankAccount'];
29
                    $postAccount = $config['postAccount'];
30
                    $paymentTo = $config['paymentTo'];
31
                    $paymentFor = $config['paymentFor'];
32
33
                    $userId = $args['user']->getId();
34
                    $amount = $args['amount'] ?? null;
35
36
                    $referenceNumber = Bvr::getReferenceNumber($bankAccount, $userId);
37
                    $encodingLine = Bvr::getEncodingLine($bankAccount, $userId, $postAccount, $amount);
0 ignored issues
show
Deprecated Code introduced by
The function Ecodev\Felix\Service\Bvr::getEncodingLine() has been deprecated: since 2.3.2 as legacy BVR is being replaced by QR bill ( Ignorable by Annotation )

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

37
                    $encodingLine = /** @scrutinizer ignore-deprecated */ Bvr::getEncodingLine($bankAccount, $userId, $postAccount, $amount);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
38
39
                    return [
40
                        'postAccount' => $postAccount,
41
                        'paymentTo' => $paymentTo,
42
                        'paymentFor' => $paymentFor,
43
                        'referenceNumber' => $referenceNumber,
44
                        'encodingLine' => $encodingLine,
45
                    ];
46 1
                },
47
            ];
48
    }
49
}
50