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

getValueProperties()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
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 gift card totals for email templates.
18
 */
19
class EbayEnterprise_GiftCard_Block_Sales_Order_Total extends Mage_Core_Block_Template
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 TOTAL_CODE = 'ebayenterprise_giftcard';
22
    const TOTAL_LABEL = 'EbayEnterprise_GiftCard_Order_Total_Label';
23
24
    /** @var EbayEnterprise_GiftCard_Model_Container */
25
    protected $giftcardContainer;
26
    /** @var EbayEnterprise_GiftCard_Helper_Data */
27
    protected $helper;
28
29 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...
30
    {
31
        list(
32
            $this->giftcardContainer,
33
            $this->helper
34
        ) = $this->checkTypes(
35
            $this->nullCoalesce($args, 'giftcard_container', Mage::getModel('ebayenterprise_giftcard/container')),
36
            $this->nullCoalesce($args, 'helper', Mage::helper('ebayenterprise_giftcard'))
37
        );
38
        parent::__construct($args);
39
    }
40
41
    /**
42
     * Enforce type checks on construct args array.
43
     *
44
     * @param EbayEnterprise_GiftCard_Model_Container
45
     * @param EbayEnterprise_GiftCard_Helper_Data
46
     * @return array
47
     */
48
    protected function checkTypes(
0 ignored issues
show
Unused Code introduced by
The method parameter $giftcardContainer is never used
Loading history...
Unused Code introduced by
The method parameter $helper is never used
Loading history...
49
        EbayEnterprise_GiftCard_Model_Container $giftcardContainer,
50
        EbayEnterprise_GiftCard_Helper_Data $helper
51
    ) {
52
        return func_get_args();
53
    }
54
55
    /**
56
     * Fill in default values.
57
     *
58
     * @param array
59
     * @param string
60
     * @param mixed
61
     * @return mixed
62
     */
63
    protected function nullCoalesce(array $arr, $key, $default)
64
    {
65
        return isset($arr[$key]) ? $arr[$key] : $default;
66
    }
67
68
    /**
69
     * Get the current order model.
70
     *
71
     * @return Mage_Sales_Model_Order
72
     */
73
    public function getOrder()
74
    {
75
        return $this->getParentBlock()->getOrder();
76
    }
77
78
    /**
79
     * Register gift card totals with the order totals block.
80
     *
81
     * @return self
82
     */
83
    public function initTotals()
84
    {
85
        $total = new Varien_Object([
86
            'code' => self::TOTAL_CODE,
87
            // Using a block name instead of just adding values so a template
88
            // can be used to render the gift card totals.
89
            'block_name' => $this->getNameInLayout(),
90
            'label' => $this->helper->__(self::TOTAL_LABEL),
91
        ]);
92
        $this->getParentBlock()->addTotalBefore($total, ['customerbalance', 'grand_total']);
93
        return $this;
94
    }
95
96
    /**
97
     * Get all gift cards redeemed for the order.
98
     *
99
     * @return SPLObjectStorage
100
     */
101
    public function getGiftCards()
102
    {
103
        return $this->giftcardContainer->getRedeemedGiftCards();
104
    }
105
106
    /**
107
     * Get the label to use for a gift card in the totals.
108
     *
109
     * @param EbayEnterprise_GiftCard_Model_Giftcard
110
     * @return string
111
     */
112
    public function getCardLabel(EbayEnterprise_GiftCard_Model_Giftcard $card)
113
    {
114
        return $this->__(self::TOTAL_LABEL, $card->getCardNumber());
115
    }
116
117
    /**
118
     * Get the value of the gift card to display in the totals.
119
     *
120
     * @param EbayEnterprise_GiftCard_Model_Giftcard
121
     * @return string
122
     */
123
    public function getCardValue(EbayEnterprise_GiftCard_Model_Giftcard $card)
124
    {
125
        return $this->getOrder()->formatPrice($card->getAmountRedeemed() * -1);
126
    }
127
128
    /**
129
     * Attributes to add to the html element wrapping the total's label.
130
     *
131
     * @return string
132
     */
133
    public function getLabelProperties()
134
    {
135
        return $this->getParentBlock()->getLabelProperties();
136
    }
137
138
    /**
139
     * Attributes to add to the html element wrapping the total's value.
140
     *
141
     * @return string
142
     */
143
    public function getValueProperties()
144
    {
145
        return $this->getParentBlock()->getValueProperties();
146
    }
147
}
148