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.

EddMessage   A
last analyzed

Complexity

Total Complexity 27

Size/Duplication

Total Lines 135
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 27
c 3
b 0
f 0
lcom 2
cbo 2
dl 0
loc 135
rs 10

15 Methods

Rating   Name   Duplication   Size   Complexity  
A getMode() 0 4 1
A getMessageType() 0 4 1
A getTemplate() 0 4 1
A getRootNodeName() 0 4 1
A getRootAttributes() 0 4 1
A getXmlNamespace() 0 4 1
A __construct() 0 21 1
B deserializeExtra() 0 12 7
A setMode() 0 5 1
A setMessageType() 0 5 1
A setTemplate() 0 5 1
A serializeContents() 0 7 1
A serializeMode() 0 6 3
A serializeMessageType() 0 6 3
A serializeTemplate() 0 6 3
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\OrderEvents;
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\TPayload;
24
use Psr\Log\LoggerInterface;
25
use Psr\Log\NullLogger;
26
27
class EddMessage implements IEddMessage
28
{
29
    use TPayload, TDeliveryWindow;
30
31
    /** @var string */
32
    protected $mode;
33
    /** @var string */
34
    protected $messageType;
35
    /** @var string */
36
    protected $template;
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,
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...
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->parentPayload = $parentPayload;
56
57
        $this->extractionPaths = [
58
            'mode' => 'string(x:Mode)',
59
            'messageType' => 'string(x:MessageType)',
60
            'template' => 'string(x:Template)',
61
        ];
62
        $this->optionalExtractionPaths = [
63
            'to' => 'x:DeliveryWindow/x:To',
64
            'from' => 'x:DeliveryWindow/x:From',
65
        ];
66
    }
67
68
    /**
69
     * @param string
70
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
71
     */
72
    protected function deserializeExtra($serializedPayload)
0 ignored issues
show
Unused Code introduced by
The parameter $serializedPayload 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...
73
    {
74
        $from = $this->getFrom();
75
        $to = $this->getTo();
76
        if (!$from instanceof DateTime && !empty($from) && is_string($from)) {
77
            $this->setFrom($from);
78
        }
79
        if (!$to instanceof DateTime && !empty($to) && is_string($to)) {
80
            $this->setTo($to);
81
        }
82
        return $this;
83
    }
84
85
    public function getMode()
86
    {
87
        return $this->mode;
88
    }
89
90
    public function setMode($mode)
91
    {
92
        $this->mode = $mode;
93
        return $this;
94
    }
95
96
    public function getMessageType()
97
    {
98
        return $this->messageType;
99
    }
100
101
    public function setMessageType($messageType)
102
    {
103
        $this->messageType = $messageType;
104
        return $this;
105
    }
106
107
    public function getTemplate()
108
    {
109
        return $this->template;
110
    }
111
112
    public function setTemplate($template)
113
    {
114
        $this->template = $template;
115
        return $this;
116
    }
117
118
    protected function getRootNodeName()
119
    {
120
        return static::ROOT_NODE;
121
    }
122
123
    protected function getRootAttributes()
124
    {
125
        return [];
126
    }
127
128
    protected function serializeContents()
129
    {
130
        return $this->serializeMode()
131
            . $this->serializeMessageType()
132
            . $this->serializeTemplate()
133
            . $this->serializeDeliveryWindow();
134
    }
135
136
    protected function serializeMode()
137
    {
138
        $mode = $this->getMode();
139
        return (!empty($mode) && is_string($mode))
140
            ? "<Mode>$mode</Mode>" : '';
141
    }
142
143
    protected function serializeMessageType()
144
    {
145
        $messageType = $this->getMessageType();
146
        return (!empty($messageType) && is_string($messageType))
147
            ? "<MessageType>$messageType</MessageType>" : '';
148
    }
149
150
    protected function serializeTemplate()
151
    {
152
        $template = $this->getTemplate();
153
        return (!empty($template) && is_string($template))
154
            ? "<Template>$template</Template>" : '';
155
    }
156
157
    protected function getXmlNamespace()
158
    {
159
        return self::XML_NS;
160
    }
161
}
162