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.

DestinationIterable::deserialize()   B
last analyzed

Complexity

Conditions 5
Paths 7

Size

Total Lines 20
Code Lines 15

Duplication

Lines 20
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 20
loc 20
rs 8.8571
cc 5
eloc 15
nc 7
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
namespace eBayEnterprise\RetailOrderManagement\Payload\TaxDutyFee;
17
18
use BadMethodCallException;
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 Psr\Log\LoggerInterface;
25
use SPLObjectStorage;
26
27
class DestinationIterable extends SPLObjectStorage implements IDestinationIterable
28
{
29
    use TIterablePayload;
30
31
    const SUBPAYLOAD_XPATH = 'x:MailingAddress|x:Email';
32
    const ROOT_NODE = 'Destinations';
33
34
    /**
35
     * @param IValidatorIterator
36
     * @param ISchemaValidator
37
     * @param IPayloadMap
38
     * @param LoggerInterface
39
     * @param IPayload
40
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
41
     */
42
    public function __construct(
43
        IValidatorIterator $validators,
44
        ISchemaValidator $schemaValidator,
0 ignored issues
show
Unused Code introduced by
The parameter $schemaValidator 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...
45
        IPayloadMap $payloadMap,
46
        LoggerInterface $logger,
47
        IPayload $parentPayload = null
48
    ) {
49
        $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...
50
        $this->validators = $validators;
51
        $this->payloadMap = $payloadMap;
52
        $this->parentPayload = $parentPayload;
53
        $this->payloadFactory = new PayloadFactory;
54
    }
55
56 View Code Duplication
    public function deserialize($serializedData)
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...
57
    {
58
        $xpath = $this->getPayloadAsXPath($serializedData);
59
        foreach ($xpath->query($this->getSubpayloadXPath()) as $subpayloadNode) {
60
            switch ($subpayloadNode->nodeName) {
61
                case 'MailingAddress':
62
                    $pl = $this->getEmptyMailingAddress();
63
                    break;
64
                case 'Email':
65
                    $pl = $this->getEmptyEmailAddress();
66
                    break;
67
            }
68
            if (isset($pl)) {
69
                $pl->deserialize($subpayloadNode->C14N());
70
                $this->offsetSet($pl);
71
            }
72
        }
73
        $this->validate();
74
        return $this;
75
    }
76
77
    protected function serializeContents()
78
    {
79
        $emailDestinations = '';
80
        $mailingDestinations = '';
81
        foreach ($this as $destination) {
82
            if ($destination instanceof IEmailAddressDestination) {
83
                $emailDestinations .= $destination->serialize();
84
            } else {
85
                $mailingDestinations .= $destination->serialize();
86
            }
87
        }
88
        return $mailingDestinations . $emailDestinations;
89
    }
90
91
    public function getNewSubpayload()
92
    {
93
        throw new BadMethodCallException('Method not supported for this type.');
94
    }
95
96
    /**
97
     * Get a new, empty mailing address destination object.
98
     *
99
     * @return IMailingAddress
100
     */
101
    public function getEmptyMailingAddress()
102
    {
103
        return $this->buildPayloadForInterface(static::MAILING_ADDRESS_INTERFACE);
104
    }
105
106
    /**
107
     * Get a new, empty store location destination object.
108
     *
109
     * @return IStoreLocation
110
     */
111
    public function getEmptyStoreLocation()
112
    {
113
        return $this->buildPayloadForInterface(static::STORE_LOCATION_INTERFACE);
114
    }
115
116
    /**
117
     * Get a new, empty email address destination object.
118
     *
119
     * @return IEmailAddressDestination
120
     */
121
    public function getEmptyEmailAddress()
122
    {
123
        return $this->buildPayloadForInterface(static::EMAIL_ADDRESS_INTERFACE);
124
    }
125
}
126