1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Omniva; |
4
|
|
|
use Omniva\Service; |
5
|
|
|
use Omniva\Address; |
6
|
|
|
use ArrayIterator; |
7
|
|
|
|
8
|
|
|
class Parcel |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* weight in kilograms |
12
|
|
|
*/ |
13
|
|
|
private $weight; |
14
|
|
|
|
15
|
|
|
private $services; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* amount in euros |
19
|
|
|
*/ |
20
|
|
|
private $codAmount; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* bank account number (IBAN) |
24
|
|
|
*/ |
25
|
|
|
private $bankAccount; |
26
|
|
|
|
27
|
|
|
private $comment; |
28
|
|
|
private $partnerId; |
29
|
|
|
|
30
|
|
|
private $receiver; |
31
|
|
|
private $returnee; |
32
|
|
|
private $sender; |
33
|
|
|
|
34
|
|
|
private $trackingNumber; |
35
|
|
|
|
36
|
|
|
public function __construct() |
37
|
|
|
{ |
38
|
|
|
$this->services = new ArrayIterator(); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* in grams |
43
|
|
|
*/ |
44
|
|
|
public function setWeight(float $weight) |
45
|
|
|
{ |
46
|
|
|
$this->weight = $weight; |
47
|
|
|
return $this; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function getWeight(): float |
51
|
|
|
{ |
52
|
|
|
return $this->weight; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function setComment(string $comment): self |
56
|
|
|
{ |
57
|
|
|
$this->comment = $comment; |
58
|
|
|
return $this; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function hasComment(): bool |
62
|
|
|
{ |
63
|
|
|
return !is_null($this->comment); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function getComment(): string |
67
|
|
|
{ |
68
|
|
|
return $this->comment; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function setPartnerId(string $partnerId): self |
72
|
|
|
{ |
73
|
|
|
$this->partnerId = $partnerId; |
74
|
|
|
return $this; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function getPartnerId(): string |
78
|
|
|
{ |
79
|
|
|
return $this->partnerId; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function setCodAmount(float $amount): self |
83
|
|
|
{ |
84
|
|
|
$this->codAmount = $amount; |
85
|
|
|
return $this; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function getCodAmount(): ?float |
89
|
|
|
{ |
90
|
|
|
return $this->codAmount; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function setBankAccount(string $number): self |
94
|
|
|
{ |
95
|
|
|
$this->bankAccount = $number; |
96
|
|
|
return $this; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
public function getBankAccount(): string |
100
|
|
|
{ |
101
|
|
|
return $this->bankAccount; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function hasServices(): bool |
105
|
|
|
{ |
106
|
|
|
return $this->services->count() > 0; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
public function addService(Service $service): self |
110
|
|
|
{ |
111
|
|
|
$this->services->append($service); |
112
|
|
|
return $this; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
public function getServices(): ArrayIterator |
116
|
|
|
{ |
117
|
|
|
return $this->services; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
public function setSender(Address $sender): self |
121
|
|
|
{ |
122
|
|
|
$this->sender = $sender; |
123
|
|
|
return $this; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
public function getSender(): Address |
127
|
|
|
{ |
128
|
|
|
return $this->sender; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
public function setReceiver(Address $receiver): self |
132
|
|
|
{ |
133
|
|
|
$this->receiver = $receiver; |
134
|
|
|
return $this; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
public function getReceiver(): Address |
138
|
|
|
{ |
139
|
|
|
return $this->receiver; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
public function setReturnee(Address $returnee): self |
143
|
|
|
{ |
144
|
|
|
$this->returnee = $returnee; |
145
|
|
|
return $this; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
public function getReturnee(): Address |
149
|
|
|
{ |
150
|
|
|
return $this->returnee; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
public function hasTrackingNumber(): bool |
154
|
|
|
{ |
155
|
|
|
return !is_null($this->trackingNumber); |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
public function getTrackingNumber(): string |
159
|
|
|
{ |
160
|
|
|
return $this->trackingNumber; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
public function setTrackingNumber(string $number): self |
164
|
|
|
{ |
165
|
|
|
$this->trackingNumber = $number; |
166
|
|
|
return $this; |
167
|
|
|
} |
168
|
|
|
} |
169
|
|
|
|