| 1 |
<?php |
| 2 |
/** |
| 3 |
* Class CustomsDeclaration |
| 4 |
* |
| 5 |
* @package Packetery |
| 6 |
*/ |
| 7 |
|
| 8 |
declare( strict_types=1 ); |
| 9 |
|
| 10 |
namespace Packetery\Core\Entity; |
| 11 |
|
| 12 |
/** |
| 13 |
* Class CustomsDeclaration |
| 14 |
*/ |
| 15 |
class CustomsDeclaration { |
| 16 |
|
| 17 |
/** |
| 18 |
* Unique identifier. |
| 19 |
* |
| 20 |
* @var ?string |
| 21 |
*/ |
| 22 |
private $id; |
| 23 |
|
| 24 |
/** |
| 25 |
* Order ID. |
| 26 |
* |
| 27 |
* @var string |
| 28 |
*/ |
| 29 |
private $orderId; |
| 30 |
|
| 31 |
/** |
| 32 |
* EAD. |
| 33 |
* |
| 34 |
* @var string |
| 35 |
*/ |
| 36 |
private $ead; |
| 37 |
|
| 38 |
/** |
| 39 |
* Delivery cost. |
| 40 |
* |
| 41 |
* @var float |
| 42 |
*/ |
| 43 |
private $deliveryCost; |
| 44 |
|
| 45 |
/** |
| 46 |
* Invoice number. |
| 47 |
* |
| 48 |
* @var string |
| 49 |
*/ |
| 50 |
private $invoiceNumber; |
| 51 |
|
| 52 |
/** |
| 53 |
* Invoice issue date. |
| 54 |
* |
| 55 |
* @var \DateTimeImmutable |
| 56 |
*/ |
| 57 |
private $invoiceIssueDate; |
| 58 |
|
| 59 |
/** |
| 60 |
* Tells if invoice file has content. |
| 61 |
* |
| 62 |
* @var bool |
| 63 |
*/ |
| 64 |
private $hasInvoiceFileContent = false; |
| 65 |
|
| 66 |
/** |
| 67 |
* Invoice. |
| 68 |
* |
| 69 |
* @var callable|null |
| 70 |
*/ |
| 71 |
private $invoiceFile = null; |
| 72 |
|
| 73 |
/** |
| 74 |
* Invoice file ID. |
| 75 |
* |
| 76 |
* @var string|null |
| 77 |
*/ |
| 78 |
private $invoiceFileId = null; |
| 79 |
|
| 80 |
/** |
| 81 |
* MRN. |
| 82 |
* |
| 83 |
* @var string|null |
| 84 |
*/ |
| 85 |
private $mrn = null; |
| 86 |
|
| 87 |
/** |
| 88 |
* Tells if EAD file has content. |
| 89 |
* |
| 90 |
* @var bool |
| 91 |
*/ |
| 92 |
private $hasEadFileContent = false; |
| 93 |
|
| 94 |
/** |
| 95 |
* Ead file. |
| 96 |
* |
| 97 |
* @var callable|null |
| 98 |
*/ |
| 99 |
private $eadFile = null; |
| 100 |
|
| 101 |
/** |
| 102 |
* EAD file ID. |
| 103 |
* |
| 104 |
* @var string|null |
| 105 |
*/ |
| 106 |
private $eadFileId = null; |
| 107 |
|
| 108 |
/** |
| 109 |
* Customs declaration item. |
| 110 |
* |
| 111 |
* @var CustomsDeclarationItem[] |
| 112 |
*/ |
| 113 |
private $items = []; |
| 114 |
|
| 115 |
/** |
| 116 |
* Constructor. |
| 117 |
* |
| 118 |
* @param string $orderId Order ID. |
| 119 |
* @param string $ead Ead. |
| 120 |
* @param float $deliveryCost Delivery cost. |
| 121 |
* @param string $invoiceNumber Invoice number. |
| 122 |
* @param \DateTimeImmutable $invoiceIssueDate Invoice issue date. |
| 123 |
*/ |
| 124 |
public function __construct( |
| 125 |
string $orderId, |
| 126 |
string $ead, |
| 127 |
float $deliveryCost, |
| 128 |
string $invoiceNumber, |
| 129 |
\DateTimeImmutable $invoiceIssueDate |
| 130 |
) { |
| 131 |
$this->orderId = $orderId; |
| 132 |
$this->ead = $ead; |
| 133 |
$this->deliveryCost = $deliveryCost; |
| 134 |
$this->invoiceNumber = $invoiceNumber; |
| 135 |
$this->invoiceIssueDate = $invoiceIssueDate; |
| 136 |
} |
| 137 |
|
| 138 |
/** |
| 139 |
* Gets delivery cost. |
| 140 |
* |
| 141 |
* @return float |
| 142 |
*/ |
| 143 |
public function getDeliveryCost(): float { |
| 144 |
return $this->deliveryCost; |
| 145 |
} |
| 146 |
|
| 147 |
/** |
| 148 |
* Sets delivery cost. |
| 149 |
* |
| 150 |
* @param float $deliveryCost Delivery cost. |
| 151 |
* |
| 152 |
* @return void |
| 153 |
*/ |
| 154 |
public function setDeliveryCost( float $deliveryCost ): void { |
| 155 |
$this->deliveryCost = $deliveryCost; |
| 156 |
} |
| 157 |
|
| 158 |
/** |
| 159 |
* Gets EAD. |
| 160 |
* |
| 161 |
* @return string |
| 162 |
*/ |
| 163 |
public function getEad(): string { |
| 164 |
return $this->ead; |
| 165 |
} |
| 166 |
|
| 167 |
/** |
| 168 |
* Set EAD. |
| 169 |
* |
| 170 |
* @param string $ead EAD. |
| 171 |
* |
| 172 |
* @return void |
| 173 |
*/ |
| 174 |
public function setEad( string $ead ): void { |
| 175 |
$this->ead = $ead; |
| 176 |
} |
| 177 |
|
| 178 |
/** |
| 179 |
* Gets EAD file. |
| 180 |
* |
| 181 |
* @return string|null |
| 182 |
*/ |
| 183 |
public function getEadFile(): ?string { |
| 184 |
if ( $this->eadFile === null ) { |
| 185 |
return null; |
| 186 |
} |
| 187 |
|
| 188 |
return call_user_func( $this->eadFile ); |
| 189 |
} |
| 190 |
|
| 191 |
/** |
| 192 |
* Sets EAD PDF file content. |
| 193 |
* |
| 194 |
* @param callable|null $eadFile EAD file content. |
| 195 |
* @param bool $hasContent Tells if file has content. |
| 196 |
* |
| 197 |
* @return void |
| 198 |
*/ |
| 199 |
public function setEadFile( ?callable $eadFile, bool $hasContent ): void { |
| 200 |
$this->eadFile = $eadFile; |
| 201 |
$this->hasEadFileContent = $hasContent; |
| 202 |
} |
| 203 |
|
| 204 |
/** |
| 205 |
* Gets EAD file ID. |
| 206 |
* |
| 207 |
* @return string|null |
| 208 |
*/ |
| 209 |
public function getEadFileId(): ?string { |
| 210 |
return $this->eadFileId; |
| 211 |
} |
| 212 |
|
| 213 |
/** |
| 214 |
* Sets EAD file ID. |
| 215 |
* |
| 216 |
* @param string|null $eadFileId EAD file ID. |
| 217 |
* |
| 218 |
* @return void |
| 219 |
*/ |
| 220 |
public function setEadFileId( ?string $eadFileId ): void { |
| 221 |
$this->eadFileId = $eadFileId; |
| 222 |
} |
| 223 |
|
| 224 |
/** |
| 225 |
* Gets ID. |
| 226 |
* |
| 227 |
* @return string|null |
| 228 |
*/ |
| 229 |
public function getId(): ?string { |
| 230 |
return $this->id; |
| 231 |
} |
| 232 |
|
| 233 |
/** |
| 234 |
* Sets ID. |
| 235 |
* |
| 236 |
* @param string|null $id ID. |
| 237 |
* |
| 238 |
* @return void |
| 239 |
*/ |
| 240 |
public function setId( ?string $id ): void { |
| 241 |
$this->id = $id; |
| 242 |
} |
| 243 |
|
| 244 |
/** |
| 245 |
* Gets invoice. |
| 246 |
* |
| 247 |
* @return string|null |
| 248 |
*/ |
| 249 |
public function getInvoiceFile(): ?string { |
| 250 |
if ( $this->invoiceFile === null ) { |
| 251 |
return null; |
| 252 |
} |
| 253 |
|
| 254 |
return call_user_func( $this->invoiceFile ); |
| 255 |
} |
| 256 |
|
| 257 |
/** |
| 258 |
* Sets invoice. |
| 259 |
* |
| 260 |
* @param callable|null $invoice Invoice. |
| 261 |
* @param bool $hasContent Tells if file has content. |
| 262 |
* |
| 263 |
* @return void |
| 264 |
*/ |
| 265 |
public function setInvoiceFile( ?callable $invoice, bool $hasContent ): void { |
| 266 |
$this->invoiceFile = $invoice; |
| 267 |
$this->hasInvoiceFileContent = $hasContent; |
| 268 |
} |
| 269 |
|
| 270 |
/** |
| 271 |
* Gets invoice file ID. |
| 272 |
* |
| 273 |
* @return string|null |
| 274 |
*/ |
| 275 |
public function getInvoiceFileId(): ?string { |
| 276 |
return $this->invoiceFileId; |
| 277 |
} |
| 278 |
|
| 279 |
/** |
| 280 |
* Sets invoice file ID. |
| 281 |
* |
| 282 |
* @param string|null $invoiceFileId Invoice file ID. |
| 283 |
* |
| 284 |
* @return void |
| 285 |
*/ |
| 286 |
public function setInvoiceFileId( ?string $invoiceFileId ): void { |
| 287 |
$this->invoiceFileId = $invoiceFileId; |
| 288 |
} |
| 289 |
|
| 290 |
/** |
| 291 |
* Gets invoice issue date. |
| 292 |
* |
| 293 |
* @return \DateTimeImmutable |
| 294 |
*/ |
| 295 |
public function getInvoiceIssueDate(): \DateTimeImmutable { |
| 296 |
return $this->invoiceIssueDate; |
| 297 |
} |
| 298 |
|
| 299 |
/** |
| 300 |
* Sets invoice issue date. |
| 301 |
* |
| 302 |
* @param \DateTimeImmutable $invoiceIssueDate Invoice issue date. |
| 303 |
* |
| 304 |
* @return void |
| 305 |
*/ |
| 306 |
public function setInvoiceIssueDate( \DateTimeImmutable $invoiceIssueDate ): void { |
| 307 |
$this->invoiceIssueDate = $invoiceIssueDate; |
| 308 |
} |
| 309 |
|
| 310 |
/** |
| 311 |
* Gets invoice number. |
| 312 |
* |
| 313 |
* @return string |
| 314 |
*/ |
| 315 |
public function getInvoiceNumber(): string { |
| 316 |
return $this->invoiceNumber; |
| 317 |
} |
| 318 |
|
| 319 |
/** |
| 320 |
* Sets invoice number. |
| 321 |
* |
| 322 |
* @param string $invoiceNumber Invoice number. |
| 323 |
* |
| 324 |
* @return void |
| 325 |
*/ |
| 326 |
public function setInvoiceNumber( string $invoiceNumber ): void { |
| 327 |
$this->invoiceNumber = $invoiceNumber; |
| 328 |
} |
| 329 |
|
| 330 |
/** |
| 331 |
* Gets items. |
| 332 |
* |
| 333 |
* @return CustomsDeclarationItem[] |
| 334 |
*/ |
| 335 |
public function getItems(): array { |
| 336 |
return $this->items; |
| 337 |
} |
| 338 |
|
| 339 |
/** |
| 340 |
* Sets items. |
| 341 |
* |
| 342 |
* @param CustomsDeclarationItem[] $items Items. |
| 343 |
* |
| 344 |
* @return void |
| 345 |
*/ |
| 346 |
public function setItems( array $items ): void { |
| 347 |
$this->items = $items; |
| 348 |
} |
| 349 |
|
| 350 |
/** |
| 351 |
* Gets MRN. |
| 352 |
* |
| 353 |
* @return string|null |
| 354 |
*/ |
| 355 |
public function getMrn(): ?string { |
| 356 |
return $this->mrn; |
| 357 |
} |
| 358 |
|
| 359 |
/** |
| 360 |
* Sets MRN. |
| 361 |
* |
| 362 |
* @param string|null $mrn MRN. |
| 363 |
* |
| 364 |
* @return void |
| 365 |
*/ |
| 366 |
public function setMrn( ?string $mrn ): void { |
| 367 |
$this->mrn = $mrn; |
| 368 |
} |
| 369 |
|
| 370 |
/** |
| 371 |
* Get order ID. |
| 372 |
* |
| 373 |
* @return string|null |
| 374 |
*/ |
| 375 |
public function getOrderId(): ?string { |
| 376 |
return $this->orderId; |
| 377 |
} |
| 378 |
|
| 379 |
/** |
| 380 |
* Tells if EAD file is present. |
| 381 |
* |
| 382 |
* @return bool |
| 383 |
*/ |
| 384 |
public function hasEadFileContent(): bool { |
| 385 |
return $this->hasEadFileContent; |
| 386 |
} |
| 387 |
|
| 388 |
/** |
| 389 |
* Tells if invoice file is set. |
| 390 |
* |
| 391 |
* @return bool |
| 392 |
*/ |
| 393 |
public function hasInvoiceFileContent(): bool { |
| 394 |
return $this->hasInvoiceFileContent; |
| 395 |
} |
| 396 |
} |
| 397 |
|