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\IPayload; |
19
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\IPayloadMap; |
20
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\ISchemaValidator; |
21
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\IValidatorIterator; |
22
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\TTopLevelPayload; |
23
|
|
|
use Psr\Log\LoggerInterface; |
24
|
|
|
use Psr\Log\NullLogger; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Class ProtectPanReply |
28
|
|
|
* @package eBayEnterprise\RetailOrderManagement\Payload\Payment |
29
|
|
|
*/ |
30
|
|
View Code Duplication |
class ProtectPanReply implements IProtectPanReply |
|
|
|
|
31
|
|
|
{ |
32
|
|
|
use TTopLevelPayload; |
33
|
|
|
|
34
|
|
|
/** @var string */ |
35
|
|
|
protected $token; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @param IValidatorIterator |
39
|
|
|
* @param ISchemaValidator |
40
|
|
|
* @param IPayloadMap |
41
|
|
|
* @param LoggerInterface |
42
|
|
|
* @param IPayload |
43
|
|
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter) |
44
|
|
|
*/ |
45
|
|
|
public function __construct( |
46
|
|
|
IValidatorIterator $validators, |
47
|
|
|
ISchemaValidator $schemaValidator, |
48
|
|
|
IPayloadMap $payloadMap, |
|
|
|
|
49
|
|
|
LoggerInterface $logger, |
50
|
|
|
IPayload $parentPayload = null |
51
|
|
|
) { |
52
|
|
|
$this->logger = $logger; |
|
|
|
|
53
|
|
|
$this->validators = $validators; |
54
|
|
|
$this->schemaValidator = $schemaValidator; |
55
|
|
|
$this->parentPayload = $parentPayload; |
56
|
|
|
|
57
|
|
|
$this->extractionPaths = [ |
58
|
|
|
'token' => 'string(x:Token)', |
59
|
|
|
]; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function getToken() |
63
|
|
|
{ |
64
|
|
|
return $this->token; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Serialize the various parts of the payload into XML strings and |
69
|
|
|
* simply concatenate them together. |
70
|
|
|
* @return string |
71
|
|
|
*/ |
72
|
|
|
protected function serializeContents() |
73
|
|
|
{ |
74
|
|
|
return $this->serializeRequiredValue('Token', $this->getToken()); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
protected function getSchemaFile() |
78
|
|
|
{ |
79
|
|
|
return $this->getSchemaDir() . self::XSD; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Return the name of the xml root node. |
84
|
|
|
* |
85
|
|
|
* @return string |
86
|
|
|
*/ |
87
|
|
|
protected function getRootNodeName() |
88
|
|
|
{ |
89
|
|
|
return static::ROOT_NODE; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* The XML namespace for the payload. |
94
|
|
|
* |
95
|
|
|
* @return string |
96
|
|
|
*/ |
97
|
|
|
protected function getXmlNamespace() |
98
|
|
|
{ |
99
|
|
|
return static::XML_NS; |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|
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.