DataAssignBoletoObserver   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 22
c 1
b 0
f 0
dl 0
loc 58
rs 10
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 23 5
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\Observer;
10
11
use Magento\Framework\Event\Observer;
0 ignored issues
show
Bug introduced by
The type Magento\Framework\Event\Observer 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\Observer\AbstractDataAssignObserver;
0 ignored issues
show
Bug introduced by
The type Magento\Payment\Observer...tractDataAssignObserver 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\Quote\Api\Data\PaymentInterface;
0 ignored issues
show
Bug introduced by
The type Magento\Quote\Api\Data\PaymentInterface 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 DataAssignBoletoObserver - Captures payment information by boleto.
17
 */
18
class DataAssignBoletoObserver extends AbstractDataAssignObserver
19
{
20
    /**
21
     * @const Method Name Block
22
     */
23
    const METHOD_NAME = 'method_name';
24
25
    /**
26
     * @const Method Name
27
     */
28
    const METHOD_NAME_TYPE = 'Boleto Bancário';
29
30
    /**
31
     * @const Holder Full Nane
32
     */
33
    const PAYER_FULLNAME = 'boleto_payer_fullname';
34
35
    /**
36
     * @const Holder Tax Document
37
     */
38
    const PAYER_TAX_DOCUMENT = 'boleto_payer_tax_document';
39
40
    /**
41
     * @var array
42
     */
43
    protected $addInformationList = [
44
        self::PAYER_FULLNAME,
45
        self::PAYER_TAX_DOCUMENT,
46
    ];
47
48
    /**
49
     * @param Observer $observer
50
     *
51
     * @return void
52
     */
53
    public function execute(Observer $observer)
54
    {
55
        $data = $this->readDataArgument($observer);
56
57
        $additionalData = $data->getData(PaymentInterface::KEY_ADDITIONAL_DATA);
58
59
        if (!is_array($additionalData)) {
60
            return;
61
        }
62
63
        $paymentInfo = $this->readPaymentModelArgument($observer);
64
65
        $paymentInfo->setAdditionalInformation(
66
            self::METHOD_NAME,
67
            self::METHOD_NAME_TYPE
68
        );
69
70
        foreach ($this->addInformationList as $addInformationKey) {
71
            if (isset($additionalData[$addInformationKey])) {
72
                if ($additionalData[$addInformationKey]) {
73
                    $paymentInfo->setAdditionalInformation(
74
                        $addInformationKey,
75
                        $additionalData[$addInformationKey]
76
                    );
77
                }
78
            }
79
        }
80
    }
81
}
82