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 ( 65c2b5...b49898 )
by
unknown
07:47
created

ProtectPanRequest::serializeContents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4286
cc 1
eloc 3
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
namespace eBayEnterprise\RetailOrderManagement\Payload\Payment;
17
18
use eBayEnterprise\RetailOrderManagement\Payload\ISchemaValidator;
19
use eBayEnterprise\RetailOrderManagement\Payload\IValidatorIterator;
20
use eBayEnterprise\RetailOrderManagement\Payload\IPayloadMap;
21
use eBayEnterprise\RetailOrderManagement\Payload\IPayload;
22
use eBayEnterprise\RetailOrderManagement\Payload\TPayloadLogger;
23
use eBayEnterprise\RetailOrderManagement\Payload\TTopLevelPayload;
24
use Psr\Log\LoggerInterface;
25
use Psr\Log\NullLogger;
26
27
class ProtectPanRequest implements IProtectPanRequest
28
{
29
    use TTopLevelPayload, TPayloadLogger;
30
31
    /** @var string */
32
    protected $paymentAccountNumber;
33
    /** @var string */
34
    protected $tenderClass;
35
    /** @var array */
36
    protected $tenderClassEnum = [self::TENDER_CLASS_CC, self::TENDER_CLASS_PL_CC, self::TENDER_CLASS_SV,];
37
38
    /**
39
     * @param IValidatorIterator
40
     * @param ISchemaValidator
41
     * @param IPayloadMap
42
     * @param LoggerInterface
43
     * @param IPayload
44
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
45
     */
46
    public function __construct(
47
        IValidatorIterator $validators,
48
        ISchemaValidator $schemaValidator,
49
        IPayloadMap $payloadMap,
0 ignored issues
show
Unused Code introduced by
The parameter $payloadMap is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
50
        LoggerInterface $logger,
51
        IPayload $parentPayload = null
52
    ) {
53
        $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...
54
        $this->validators = $validators;
55
        $this->schemaValidator = $schemaValidator;
56
        $this->parentPayload = $parentPayload;
57
58
        $this->extractionPaths = [
59
            'paymentAccountNumber' => 'string(x:PaymentAccountNumber)',
60
            'tenderClass' => 'string(x:TenderClass)',
61
        ];
62
    }
63
64
65
    public function getPaymentAccountNumber()
66
    {
67
        return $this->paymentAccountNumber;
68
    }
69
70
    public function setPaymentAccountNumber($paymentAccountNumber)
71
    {
72
        $this->paymentAccountNumber = $this->cleanString($paymentAccountNumber, 50);
73
        return $this;
74
    }
75
76
    public function getTenderClass()
77
    {
78
        return $this->tenderClass;
79
    }
80
81 View Code Duplication
    public function setTenderClass($tenderClass)
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...
82
    {
83
        $isAllowed = in_array($tenderClass, $this->tenderClassEnum);
84
        $this->tenderClass = $isAllowed ? $tenderClass : null;
85
        if (!$isAllowed) {
86
            $logData = ['tender_class' => $tenderClass];
87
            $this->logger->warning(
88
                'Tender Class "{tender_class}" is not allowed.',
89
                $this->getLogContextData(__CLASS__, $logData)
90
            );
91
        }
92
        return $this;
93
    }
94
95
    /**
96
     * Serialize the various parts of the payload into XML strings and
97
     * simply concatenate them together.
98
     * @return string
99
     */
100
    protected function serializeContents()
101
    {
102
        return $this->serializeRequiredValue('PaymentAccountNumber', $this->xmlEncode($this->getPaymentAccountNumber()))
103
            . $this->serializeRequiredValue('TenderClass', $this->xmlEncode($this->getTenderClass()));
104
    }
105
106
    /**
107
     * The XML namespace for the payload.
108
     *
109
     * @return string
110
     */
111
    protected function getXmlNamespace()
112
    {
113
        return static::XML_NS;
114
    }
115
116
    protected function getSchemaFile()
117
    {
118
        return $this->getSchemaDir() . self::XSD;
119
    }
120
121
    /**
122
     * Return the name of the xml root node.
123
     *
124
     * @return string
125
     */
126
    protected function getRootNodeName()
127
    {
128
        return static::ROOT_NODE;
129
    }
130
}
131