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 ( a7ee1a...52140c )
by
unknown
82:37 queued 11:46
created

isPanTokenize()   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 1
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
use \eBayEnterprise\RetailOrderManagement\Payload\Order\IPaymentContainer;
17
18
class EbayEnterprise_Giftcard_Model_Order_Create_Payment
19
{
20
    /** @var EbayEnterprise_GiftCard_Model_IContainer */
21
    protected $_giftcardContainer;
22
    public function __construct(array $args = [])
23
    {
24
        list(
25
            $this->_giftcardContainer
26
        ) = $this->_enforceTypes(
27
            $this->_nullCoalesce('giftcard_container', $args, Mage::getModel('ebayenterprise_giftcard/container'))
28
        );
29
    }
30
31
    /**
32
     * ensure correct types
33
     * @param  EbayEnterprise_GiftCard_Model_IContainer $container
34
     * @return array
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use EbayEnterprise_GiftCard_Model_IContainer[].

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
35
     */
36
    protected function _enforceTypes(EbayEnterprise_GiftCard_Model_IContainer $container)
37
    {
38
        return [$container];
39
    }
40
41
    /**
42
     * Make stored value card payloads for any redeemed
43
     * gift cards
44
     *
45
     * @param Mage_Sales_Model_Order $order
46
     * @param IPaymentContainer      $paymentContainer
47
     * @param SplObjectStorage       $processedPayments
48
     */
49
    public function addPaymentsToPayload(
50
        Mage_Sales_Model_Order $order,
51
        IPaymentContainer $paymentContainer,
52
        SplObjectStorage $processedPayments
53
    ) {
54
        foreach ($this->_giftcardContainer->getRedeemedGiftcards() as $giftcard) {
55
            $iterable = $paymentContainer->getPayments();
56
            $payload = $iterable->getEmptyStoredValueCardPayment();
57
            $payload
58
                // payment context
59
                ->setOrderId($order->getIncrementId())
60
                ->setTenderType($giftcard->getTenderType())
61
                ->setAccountUniqueId($this->getGcPan($giftcard))
62
                ->setPanIsToken($this->isPanTokenize($giftcard))
63
                // payment data
64
                ->setCreateTimestamp($giftcard->getRedeemedAt())
65
                ->setAmount($giftcard->getAmountRedeemed())
66
                ->setPin($giftcard->getPin())
67
                ->setPaymentRequestId($giftcard->getRedeemRequestId());
68
            // add the new payload
69
            $iterable->OffsetSet($payload, $payload);
70
            // put the payment in the processed payments set
71
            $processedPayments->attach($giftcard);
72
        }
73
    }
74
75
    protected function _nullCoalesce($key, array $args, $default)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
76
    {
77
        return isset($args[$key]) ? $args[$key] : $default;
78
    }
79
80
    /**
81
     * Determine if the PAN in the giftcard is tokenized.
82
     *
83
     * @param EbayEnterprise_GiftCard_Model_IGiftcard
84
     * @return bool
85
     */
86
    protected function isPanTokenize(EbayEnterprise_GiftCard_Model_IGiftcard $giftcard)
87
    {
88
        return !is_null($giftcard->getTokenizedCardNumber());
89
    }
90
91
    /**
92
     * Get the Giftcard PAN. Return the tokenized pan if it is tokenized otherwise
93
     * return the raw PAN.
94
     *
95
     * @param EbayEnterprise_GiftCard_Model_IGiftcard
96
     * @return bool
0 ignored issues
show
Documentation introduced by
Should the return type not be string?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
97
     */
98
    protected function getGcPan(EbayEnterprise_GiftCard_Model_IGiftcard $giftcard)
99
    {
100
        return $this->isPanTokenize($giftcard) ? $giftcard->getTokenizedCardNumber() : $giftcard->getCardNumber();
101
    }
102
}
103