| Conditions | 3 |
| Paths | 3 |
| Total Lines | 23 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | public function fromCdbAddress(\CultureFeed_Cdb_Data_Address_PhysicalAddress $cdbAddress) |
||
| 14 | { |
||
| 15 | $requiredFields = [ |
||
| 16 | 'street' => $cdbAddress->getStreet(), |
||
| 17 | 'house number' => $cdbAddress->getHouseNumber(), |
||
| 18 | 'zip code' => $cdbAddress->getZip(), |
||
| 19 | 'city' => $cdbAddress->getCity(), |
||
| 20 | 'country' => $cdbAddress->getCountry(), |
||
| 21 | ]; |
||
| 22 | |||
| 23 | foreach ($requiredFields as $key => $requiredField) { |
||
| 24 | if (is_null($requiredField)) { |
||
| 25 | throw new \InvalidArgumentException('The given cdbxml address is missing a ' . $key); |
||
| 26 | } |
||
| 27 | } |
||
| 28 | |||
| 29 | return new Address( |
||
| 30 | new Street($cdbAddress->getStreet() . ' ' . $cdbAddress->getHouseNumber()), |
||
| 31 | new PostalCode($cdbAddress->getZip()), |
||
| 32 | new Locality($cdbAddress->getCity()), |
||
| 33 | Country::fromNative($cdbAddress->getCountry()) |
||
| 34 | ); |
||
| 35 | } |
||
| 36 | } |
||
| 37 |