1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Iris\Mapping; |
4
|
|
|
|
5
|
|
|
class Order extends Base |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* @var \Iris\Mapping\OrderCustomer |
9
|
|
|
*/ |
10
|
|
|
private $customerMapping; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @var \Iris\Mapping\OrderAddress |
14
|
|
|
*/ |
15
|
|
|
private $addressMapping; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var \Iris\Mapping\OrderItem |
19
|
|
|
*/ |
20
|
|
|
private $itemMapping; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* {@inheritdoc} |
24
|
|
|
*/ |
25
|
1 |
|
public function assign(array $externalData) |
26
|
|
|
{ |
27
|
1 |
|
$order = new \Iris\Transfer\Sales\Order(array( |
28
|
1 |
|
'grand_total' => ($externalData['total_amount'] + $externalData['freight_amount']), |
29
|
1 |
|
'created_at' => date('Y-m-d H:i:s', strtotime($externalData['purchase_date'])), |
30
|
1 |
|
'shipping_amount' => $externalData['freight_amount'], |
31
|
1 |
|
'address' => $this->getAddressMapping()->assign($externalData['customer'], true), |
|
|
|
|
32
|
1 |
|
'item_collection' => $this->getItemMapping()->assign($externalData), |
33
|
1 |
|
'freight_cost' => $externalData['freight_cost'], |
34
|
1 |
|
'customer' => $this->getCustomerMapping()->assign($externalData['customer']) |
35
|
1 |
|
)); |
36
|
|
|
|
37
|
1 |
|
return $order; |
|
|
|
|
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @return \Iris\Mapping\OrderCustomer |
42
|
|
|
*/ |
43
|
3 |
|
public function getCustomerMapping() |
44
|
|
|
{ |
45
|
3 |
|
$this->customerMapping || $this->setCustomerMapping(OrderCustomer::getInstance()); |
46
|
3 |
|
return $this->customerMapping; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param \Iris\Mapping\OrderCustomer $map |
51
|
|
|
* @return \Iris\Mapping\Order |
52
|
|
|
*/ |
53
|
3 |
|
public function setCustomerMapping(OrderCustomer $map) |
54
|
|
|
{ |
55
|
3 |
|
$this->customerMapping = $map; |
56
|
3 |
|
return $this; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return \Iris\Mapping\OrderAddress |
61
|
|
|
*/ |
62
|
3 |
|
public function getAddressMapping() |
63
|
|
|
{ |
64
|
3 |
|
$this->addressMapping || $this->setAddressMapping(OrderAddress::getInstance()); |
65
|
3 |
|
return $this->addressMapping; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param \Iris\Mapping\OrderAddress $map |
70
|
|
|
* @return \Iris\Mapping\Order |
71
|
|
|
*/ |
72
|
3 |
|
public function setAddressMapping(OrderAddress $map) |
73
|
|
|
{ |
74
|
3 |
|
$this->addressMapping = $map; |
75
|
3 |
|
return $this; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @return \Iris\Mapping\OrderItem |
80
|
|
|
*/ |
81
|
3 |
|
public function getItemMapping() |
82
|
|
|
{ |
83
|
3 |
|
$this->itemMapping || $this->setItemMapping(OrderItem::getInstance()); |
84
|
3 |
|
return $this->itemMapping; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @param \Iris\Mapping\OrderItem $map |
89
|
|
|
* @return \Iris\Mapping\Order |
90
|
|
|
*/ |
91
|
3 |
|
public function setItemMapping(OrderItem $map) |
92
|
|
|
{ |
93
|
3 |
|
$this->itemMapping = $map; |
94
|
3 |
|
return $this; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* {@inheritdoc} |
99
|
|
|
*/ |
100
|
1 |
|
public function map($internalData) |
101
|
|
|
{ |
102
|
1 |
|
$externalData = array(); |
103
|
1 |
|
$externalData['marketplaceOrderId'] = $internalData->getOrderNr(); |
104
|
|
|
|
105
|
1 |
|
$externalData['items'] = array(); |
106
|
1 |
|
foreach ($internalData->getItemCollection() as $salesOrderItem) { |
107
|
1 |
|
$externalData['items'][] = $this->getItemMapping()->map($salesOrderItem); |
108
|
1 |
|
} |
109
|
|
|
|
110
|
1 |
|
$externalData['clientProfileData'] = $this->getCustomerMapping()->map($internalData); |
111
|
1 |
|
$externalData['shippingData'] = $this->getAddressMapping()->map($internalData); |
112
|
|
|
|
113
|
1 |
|
return $externalData; |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.