| 1 |
<?php |
| 2 |
/** |
| 3 |
* Class CreatePacket. |
| 4 |
* |
| 5 |
* @package Packetery\Api\Soap\Response |
| 6 |
*/ |
| 7 |
|
| 8 |
declare( strict_types=1 ); |
| 9 |
|
| 10 |
namespace Packetery\Core\Api\Soap\Response; |
| 11 |
|
| 12 |
/** |
| 13 |
* Class CreatePacket. |
| 14 |
* |
| 15 |
* @package Packetery\Api\Soap\Response |
| 16 |
*/ |
| 17 |
class CreatePacket extends BaseResponse { |
| 18 |
|
| 19 |
/** |
| 20 |
* Barcode without leading Z. |
| 21 |
* |
| 22 |
* @var int |
| 23 |
*/ |
| 24 |
private $id; |
| 25 |
|
| 26 |
/** |
| 27 |
* Barcode with leading Z. |
| 28 |
* |
| 29 |
* @var string |
| 30 |
*/ |
| 31 |
private $barcode; |
| 32 |
|
| 33 |
/** |
| 34 |
* Packet attributes errors. |
| 35 |
* |
| 36 |
* @var array |
| 37 |
*/ |
| 38 |
private $validationErrors; |
| 39 |
|
| 40 |
/** |
| 41 |
* Sets id. |
| 42 |
* |
| 43 |
* @param int $id Id. |
| 44 |
*/ |
| 45 |
public function setId( int $id ): void { |
| 46 |
$this->id = $id; |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* Sets barcode. |
| 51 |
* |
| 52 |
* @param string $barcode Barcode. |
| 53 |
*/ |
| 54 |
public function setBarcode( string $barcode ): void { |
| 55 |
$this->barcode = $barcode; |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* Sets errors. |
| 60 |
* |
| 61 |
* @param array $errors Errors. |
| 62 |
*/ |
| 63 |
public function setValidationErrors( array $errors ): void { |
| 64 |
$this->validationErrors = $errors; |
| 65 |
} |
| 66 |
|
| 67 |
/** |
| 68 |
* Gets id. |
| 69 |
* |
| 70 |
* @return int |
| 71 |
*/ |
| 72 |
public function getId(): int { |
| 73 |
return $this->id; |
| 74 |
} |
| 75 |
|
| 76 |
/** |
| 77 |
* Gets barcode. |
| 78 |
* |
| 79 |
* @return string |
| 80 |
*/ |
| 81 |
public function getBarcode(): string { |
| 82 |
return $this->barcode; |
| 83 |
} |
| 84 |
|
| 85 |
/** |
| 86 |
* Gets errors. |
| 87 |
* |
| 88 |
* @return array|null |
| 89 |
*/ |
| 90 |
public function getValidationErrors(): ?array { |
| 91 |
return $this->validationErrors; |
| 92 |
} |
| 93 |
|
| 94 |
/** |
| 95 |
* Gets all errors as string. |
| 96 |
* |
| 97 |
* @return string |
| 98 |
*/ |
| 99 |
public function getErrorsAsString(): string { |
| 100 |
$allErrors = $this->validationErrors; |
| 101 |
array_unshift( $allErrors, $this->getFaultString() ); |
| 102 |
|
| 103 |
return implode( ', ', $allErrors ); |
| 104 |
} |
| 105 |
} |
| 106 |
|