GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( b1489d...d608fb )
by Scott van
15:51
created

initTotals()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 17
rs 9.4285
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
/**
3
 * Copyright (c) 2013-2014 eBay Enterprise, Inc.
4
 *
5
 * NOTICE OF LICENSE
6
 *
7
 * This source file is subject to the Open Software License (OSL 3.0)
8
 * that is bundled with this package in the file LICENSE.md.
9
 * It is also available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * @copyright   Copyright (c) 2013-2014 eBay Enterprise, Inc. (http://www.ebayenterprise.com/)
13
 * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
14
 */
15
16
/**
17
 * Block for rendering eBay Enterprise tax data for email templates.
18
 */
19
class EbayEnterprise_Tax_Block_Sales_Order_Tax extends Mage_Core_Block_Abstract
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
20
{
21
    const TAX_LABEL = 'EbayEnterprise_Tax_Order_Total_Tax_Title';
22
    const TOTAL_CODE = 'ebayenterprise_tax';
23
24
    /** @var EbayEnterprise_Tax_Model_Collector */
25
    protected $taxCollector;
26
    /** @var EbayEnterprise_Tax_Helper_Data */
27
    protected $helper;
28
29
    /**
30
     * @param array May contain:
31
     *              - tax_collector => EbayEnterprise_Tax_Model_Collector
32
     */
33 View Code Duplication
    public function __construct(array $args = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
    {
35
        list(
36
            $this->taxCollector,
37
            $this->helper
38
        ) = $this->checkTypes(
39
            $this->nullCoalesce($args, 'tax_collector', Mage::getModel('ebayenterprise_tax/collector')),
40
            $this->nullCoalesce($args, 'helper', Mage::helper('ebayenterprise_tax'))
41
        );
42
        parent::__construct($args);
43
    }
44
45
    /**
46
     * Enforce type checks on construct args array.
47
     *
48
     * @param EbayEnterprise_Tax_Model_Collector
49
     * @param EbayEnterprise_Tax_Helper_Data
50
     * @return array
51
     */
52
    protected function checkTypes(
0 ignored issues
show
Unused Code introduced by
The method parameter $taxCollector is never used
Loading history...
Unused Code introduced by
The method parameter $helper is never used
Loading history...
53
        EbayEnterprise_Tax_Model_Collector $taxCollector,
54
        EbayEnterprise_Tax_Helper_Data $helper
55
    ) {
56
        return func_get_args();
57
    }
58
59
    /**
60
     * Fill in default values.
61
     *
62
     * @param array
63
     * @param string
64
     * @param mixed
65
     * @return mixed
66
     */
67
    protected function nullCoalesce(array $arr, $key, $default)
68
    {
69
        return isset($arr[$key]) ? $arr[$key] : $default;
70
    }
71
72
    /**
73
     * Add totals for collected taxes to the parent block. Totals added to the
74
     * parent will be displayed with order totals.
75
     *
76
     * @return self
77
     */
78
    public function initTotals()
79
    {
80
        $parent = $this->getParentBlock();
81
82
        $taxAmount = $this->totalTaxAmount();
83
        $parent->addTotal(
84
            new Varien_Object([
85
                'code' => self::TOTAL_CODE,
86
                'value' => $taxAmount,
87
                'base_value' => $taxAmount,
88
                'label' => $this->helper->__(self::TAX_LABEL),
89
            ]),
90
            'discount'
91
        );
92
93
        return $this;
94
    }
95
96
    /**
97
     * Total all taxes associated with the current order.
98
     *
99
     * @return float
100
     */
101
    protected function totalTaxAmount()
102
    {
103
        $records = array_reduce($this->taxCollector->getTaxRecords(), function ($total, $item) { return $total + $item->getCalculatedTax(); }, 0.00);
0 ignored issues
show
Coding Style introduced by
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
104
        $duties = array_reduce($this->taxCollector->getTaxDuties(), function ($total, $item) { return $total + $item->getAmount(); }, 0.00);
0 ignored issues
show
Coding Style introduced by
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
105
        $fees = array_reduce($this->taxCollector->getTaxFees(), function ($total, $item) { return $total + $item->getAmount(); }, 0.00);
0 ignored issues
show
Coding Style introduced by
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
106
107
        return $records + $duties + $fees;
108
    }
109
}
110