Totals   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getOrder() 0 3 1
A getSource() 0 3 1
A initTotals() 0 20 3
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\Block\Adminhtml\Sales\Order;
10
11
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...
12
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...
13
use Magento\Sales\Model\Order;
0 ignored issues
show
Bug introduced by
The type Magento\Sales\Model\Order 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 Totals - Invoice.
17
 */
18
class Totals extends Template
19
{
20
    /**
21
     * Retrieve current order model instance.
22
     *
23
     * @return Order
24
     */
25
    public function getOrder()
26
    {
27
        return $this->getParentBlock()->getOrder();
28
    }
29
30
    /**
31
     * Get Source.
32
     *
33
     * @return source
0 ignored issues
show
Bug introduced by
The type Moip\Magento2\Block\Adminhtml\Sales\Order\source 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...
34
     */
35
    public function getSource()
36
    {
37
        return $this->getParentBlock()->getSource();
38
    }
39
40
    /**
41
     * @return $this
42
     */
43
    public function initTotals()
44
    {
45
        $this->getParentBlock();
46
        $this->getOrder();
47
        $this->getSource();
48
49
        if (!$this->getSource()->getMoipInterestAmount() || (int) $this->getSource()->getMoipInterestAmount() === 0) {
50
            return $this;
51
        }
52
53
        $total = new DataObject(
54
            [
55
                'code'  => 'moip_interest',
56
                'value' => $this->getSource()->getMoipInterestAmount(),
57
                '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

57
                'label' => /** @scrutinizer ignore-call */ __('Moip Interest Amount'),
Loading history...
58
            ]
59
        );
60
        $this->getParentBlock()->addTotalBefore($total, 'grand_total');
61
62
        return $this;
63
    }
64
}
65