zangra-dev /
bpost-api-library
| 1 | <?php |
||
| 2 | declare(strict_types=1); |
||
| 3 | |||
| 4 | namespace Bpost\BpostApiClient\Bpost; |
||
| 5 | |||
| 6 | use Bpost\BpostApiClient\Bpost\ProductConfiguration\DeliveryMethod; |
||
| 7 | use SimpleXMLElement; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Class ProductConfiguration |
||
| 11 | */ |
||
| 12 | class ProductConfiguration |
||
| 13 | { |
||
| 14 | private array $deliveryMethods = []; |
||
| 15 | |||
| 16 | public function getDeliveryMethods(): array |
||
| 17 | { |
||
| 18 | return $this->deliveryMethods; |
||
| 19 | } |
||
| 20 | |||
| 21 | public function addDeliveryMethod(DeliveryMethod $deliveryMethod): void |
||
| 22 | { |
||
| 23 | $this->deliveryMethods[] = $deliveryMethod; |
||
| 24 | } |
||
| 25 | |||
| 26 | public static function createFromXML(SimpleXMLElement $xml): self |
||
| 27 | { |
||
| 28 | $productConfiguration = new self(); |
||
| 29 | |||
| 30 | if (isset($xml->deliveryMethod)) { |
||
| 31 | foreach ($xml->deliveryMethod as $deliveryMethodXml) { |
||
| 32 | $productConfiguration->addDeliveryMethod( |
||
| 33 | DeliveryMethod::createFromXML($deliveryMethodXml) |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 34 | ); |
||
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 38 | return $productConfiguration; |
||
| 39 | } |
||
| 40 | } |
||
| 41 |