Passed
Push[email protected] ( 6f4930...6fef5b )
by Bruno
13:24 queued 10:12
created

Totals::initTotals()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 22
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 12
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 22
rs 9.8666
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
declare(strict_types=1);
10
11
namespace Moip\Magento2\Block\Adminhtml\Sales\Order\Creditmemo;
12
13
use Magento\Framework\DataObject;
0 ignored issues
show
Bug introduced by
The type Magento\Framework\DataObject 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
use Magento\Framework\View\Element\Template;
0 ignored issues
show
Bug introduced by
The type Magento\Framework\View\Element\Template 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...
15
16
/**
17
 * Class Totals - Creditmemo.
18
 */
19
class Totals extends Template
20
{
21
    /**
22
     * Get data (totals) source model.
23
     *
24
     * @return DataObject
25
     */
26
    public function getSource()
27
    {
28
        return $this->getParentBlock()->getSource();
29
    }
30
31
    /**
32
     * Get Creditmemo.
33
     *
34
     * @return creditmemo
0 ignored issues
show
Bug introduced by
The type Moip\Magento2\Block\Admi...r\Creditmemo\creditmemo 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...
35
     */
36
    public function getCreditmemo()
37
    {
38
        return $this->getParentBlock()->getCreditmemo();
39
    }
40
41
    /**
42
     * Initialize payment moip_interest totals.
43
     *
44
     * @return $this
45
     */
46
    public function initTotals()
47
    {
48
        $this->getParentBlock();
49
        $this->getCreditmemo();
50
        $this->getSource();
51
52
        if (!$this->getSource()->getMoipInterestAmount()) {
53
            return $this;
54
        }
55
56
        $moip_interest = new DataObject(
57
            [
58
                'code'   => 'moip_interest',
59
                'strong' => false,
60
                'value'  => $this->getSource()->getMoipInterestAmount(),
61
                'label'  => __('Moip Interest Amount'),
0 ignored issues
show
Bug introduced by
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

61
                'label'  => /** @scrutinizer ignore-call */ __('Moip Interest Amount'),
Loading history...
62
            ]
63
        );
64
65
        $this->getParentBlock()->addTotalBefore($moip_interest, 'grand_total');
66
67
        return $this;
68
    }
69
}
70