Issues (570)

Block/Sales/Totals.php (6 issues)

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\Sales;
12
13
use Magento\Framework\DataObject;
0 ignored issues
show
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
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
use Magento\Sales\Model\Order;
0 ignored issues
show
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...
16
17
/**
18
 * Class Totals - Template.
19
 */
20
class Totals extends Template
21
{
22
    /**
23
     * @var Order
24
     */
25
    protected $_order;
26
27
    /**
28
     * @var DataObject
29
     */
30
    protected $_source;
31
32
    /**
33
     * @return bool
34
     */
35
    public function displayFullSummary()
36
    {
37
        return true;
38
    }
39
40
    /**
41
     * Get data (totals) source model.
42
     *
43
     * @return DataObject
44
     */
45
    public function getSource()
46
    {
47
        return $this->_source;
48
    }
49
50
    /**
51
     * @return store
0 ignored issues
show
The type Moip\Magento2\Block\Sales\store 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...
52
     */
53
    public function getStore()
54
    {
55
        return $this->_order->getStore();
56
    }
57
58
    /**
59
     * @return Order
60
     */
61
    public function getOrder()
62
    {
63
        return $this->_order;
64
    }
65
66
    /**
67
     * Initialize payment moip_interest totals.
68
     *
69
     * @return $this
70
     */
71
    public function initTotals()
72
    {
73
        $parent = $this->getParentBlock();
74
        $this->_order = $parent->getOrder();
75
        $this->_source = $parent->getSource();
76
77
        if (!$this->_source->getMoipInterestAmount() || (int) $this->_source->getMoipInterestAmount() === 0) {
78
            return $this;
79
        }
80
81
        $valueInterest = $this->_source->getMoipInterestAmount();
82
        $label = $this->getLabelByInterest($valueInterest);
83
        $moipInterest = new DataObject(
84
            [
85
                'code'   => 'moip_interest',
86
                'strong' => false,
87
                'value'  => $valueInterest,
88
                'label'  => $label,
89
            ]
90
        );
91
92
        if ((int) $valueInterest !== 0.0000) {
93
            $parent->addTotal($moipInterest, 'moip_interest');
94
        }
95
96
        return $this;
97
    }
98
99
    /**
100
     * Get Subtotal label by Interest.
101
     *
102
     * @param $interest | float
0 ignored issues
show
Documentation Bug introduced by
The doc comment | float at position 0 could not be parsed: Unknown type name '|' at position 0 in | float.
Loading history...
103
     *
104
     * @return Phrase
105
     */
106
    public function getLabelByInterest($interest)
107
    {
108
        if ($interest >= 0) {
109
            return __('Installment Interest');
0 ignored issues
show
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

109
            return /** @scrutinizer ignore-call */ __('Installment Interest');
Loading history...
110
        }
111
112
        return __('Discount Cash');
113
    }
114
}
115