FetchTransactionInfoRequest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 40
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 16 3
A __construct() 0 4 1
1
<?php
2
/**
3
 * Copyright © Wirecard Brasil. All rights reserved.
4
 *
5
 * @author    Bruno Elisei <[email protected]>
6
 * See COPYING.txt for license details.
7
 */
8
9
namespace Moip\Magento2\Gateway\Request;
10
11
use Magento\Payment\Gateway\ConfigInterface;
0 ignored issues
show
Bug introduced by
The type Magento\Payment\Gateway\ConfigInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Magento\Payment\Gateway\Data\PaymentDataObjectInterface;
0 ignored issues
show
Bug introduced by
The type Magento\Payment\Gateway\...mentDataObjectInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use Magento\Payment\Gateway\Request\BuilderInterface;
0 ignored issues
show
Bug introduced by
The type Magento\Payment\Gateway\Request\BuilderInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
15
/**
16
 * Class FetchTransactionInfoRequest - Transaction query data structure.
17
 */
18
class FetchTransactionInfoRequest implements BuilderInterface
19
{
20
    /**
21
     * @var Moip Order Id
22
     */
23
    const MOIP_ORDER_ID = 'moip_order_id';
24
25
    /**
26
     * @var ConfigInterface
27
     */
28
    private $config;
29
30
    /**
31
     * @param ConfigInterface $config
32
     */
33
    public function __construct(
34
        ConfigInterface $config
35
    ) {
36
        $this->config = $config;
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function build(array $buildSubject)
43
    {
44
        if (!isset($buildSubject['payment'])
45
            || !$buildSubject['payment'] instanceof PaymentDataObjectInterface
46
        ) {
47
            throw new \InvalidArgumentException('Payment data object should be provided');
48
        }
49
50
        $paymentDO = $buildSubject['payment'];
51
52
        $payment = $paymentDO->getPayment();
53
54
        $order = $payment->getOrder();
55
56
        return [
57
            self::MOIP_ORDER_ID => $order->getExtOrderId(),
58
        ];
59
    }
60
}
61