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.

StoredValueCardPayment::__construct()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 34
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 34
rs 8.8571
cc 1
eloc 26
nc 1
nop 5
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-2015 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
namespace eBayEnterprise\RetailOrderManagement\Payload\Order;
17
18
use DateTime;
19
use eBayEnterprise\RetailOrderManagement\Payload\IPayload;
20
use eBayEnterprise\RetailOrderManagement\Payload\IPayloadMap;
21
use eBayEnterprise\RetailOrderManagement\Payload\ISchemaValidator;
22
use eBayEnterprise\RetailOrderManagement\Payload\IValidatorIterator;
23
use eBayEnterprise\RetailOrderManagement\Payload\PayloadFactory;
24
use eBayEnterprise\RetailOrderManagement\Payload\Payment\TAmount;
25
use eBayEnterprise\RetailOrderManagement\Payload\TPayload;
26
use Psr\Log\LoggerInterface;
27
use Psr\Log\NullLogger;
28
29
class StoredValueCardPayment implements IStoredValueCardPayment
30
{
31
    use TPayload, TAmount, TCustomAttributeContainer, TCardPayment;
32
33
    const ROOT_NODE = 'StoredValueCard';
34
35
    /** @var DateTime */
36
    protected $createTimeStamp;
37
    /** @var float */
38
    protected $amount;
39
    /** @var string */
40
    protected $pin;
41
42
    /**
43
     * @param IValidatorIterator
44
     * @param ISchemaValidator
45
     * @param IPayloadMap
46
     * @param LoggerInterface
47
     * @param IPayload
48
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
49
     */
50
    public function __construct(
51
        IValidatorIterator $validators,
52
        ISchemaValidator $schemaValidator,
53
        IPayloadMap $payloadMap,
54
        LoggerInterface $logger,
55
        IPayload $parentPayload = null
56
    ) {
57
        $this->logger = $logger;
0 ignored issues
show
Documentation Bug introduced by
It seems like $logger of type object<Psr\Log\LoggerInterface> is incompatible with the declared type object<eBayEnterprise\Re...ayload\LoggerInterface> of property $logger.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
58
        $this->validators = $validators;
59
        $this->schemaValidator = $schemaValidator;
60
        $this->payloadMap = $payloadMap;
61
        $this->parentPayload = $parentPayload;
62
        $this->payloadFactory = new PayloadFactory;
63
64
        $this->extractionPaths = [
65
            'orderId' => 'string(x:PaymentContext/x:PaymentSessionId)',
66
            'tenderType' => 'string(x:PaymentContext/x:TenderType)',
67
            'accountUniqueId' => 'string(x:PaymentContext/x:PaymentAccountUniqueId)',
68
            'paymentRequestId' => 'string(x:PaymentRequestId)',
69
        ];
70
        $this->optionalExtractionPaths = [
71
            'amount' => 'x:Amount',
72
            'pin' => 'x:Pin',
73
        ];
74
        $this->booleanExtractionPaths = [
75
            'isMockPayment' => 'string(@isMockPayment)',
76
            'panIsToken' => 'string(x:PaymentContext/x:PaymentAccountUniqueId/@isToken)'
77
        ];
78
        $this->subpayloadExtractionPaths = [
79
            'customAttributes' => 'x:CustomAttributes',
80
        ];
81
82
        $this->customAttributes = $this->buildPayloadForInterface(self::CUSTOM_ATTRIBUTE_ITERABLE_INTERFACE);
83
    }
84
85
    public function getCreateTimeStamp()
86
    {
87
        return $this->createTimeStamp;
88
    }
89
90
    public function setCreateTimeStamp(DateTime $createTimeStamp)
91
    {
92
        $this->createTimeStamp = $createTimeStamp;
93
        return $this;
94
    }
95
96
    public function getAmount()
97
    {
98
        return $this->amount;
99
    }
100
101
    public function setAmount($amount)
102
    {
103
        $this->amount = $this->sanitizeAmount($amount);
104
        return $this;
105
    }
106
107
    public function getPin()
108
    {
109
        return $this->pin;
110
    }
111
112
    public function setPin($pin)
113
    {
114
        $this->pin = $this->cleanString($pin, 22);
115
        return $this;
116
    }
117
118
    protected function serializeContents()
119
    {
120
        return $this->serializePaymentContext()
121
            . $this->serializePaymentRequestId()
122
            . "<CreateTimeStamp>{$this->getCreateTimeStamp()->format('c')}</CreateTimeStamp>"
123
            . $this->serializeOptionalXmlEncodedValue('Pin', $this->getPin())
124
            . $this->serializeAmount('Amount', $this->getAmount())
125
            . $this->getCustomAttributes()->serialize();
126
    }
127
128 View Code Duplication
    protected function deserializeExtra($serializedPayload)
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...
129
    {
130
        $xpath = $this->getPayloadAsXPath($serializedPayload);
131
        $createTimestampValue = $xpath->evaluate('string(x:CreateTimeStamp)');
132
        $this->createTimeStamp = $createTimestampValue ? new DateTime($createTimestampValue) : null;
133
        return $this;
134
    }
135
136 View Code Duplication
    protected function getRootAttributes()
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...
137
    {
138
        $isMockPayment = $this->getIsMockPayment();
139
        return !is_null($isMockPayment)
140
            ? ['isMockPayment' => $this->convertBooleanToString($isMockPayment)]
141
            : [];
142
    }
143
144
    protected function getRootNodeName()
145
    {
146
        return static::ROOT_NODE;
147
    }
148
149
    protected function getXmlNamespace()
150
    {
151
        return self::XML_NS;
152
    }
153
}
154