Ejemplo n.º 1
0
 /**
  * Basic sample Address creation from an array, feel free to implement your own
  * @param  array  $address
  * @return Address
  */
 public static function fromArray(array $address)
 {
     $street = ['number' => self::getArrayValueFromKeyOrNull($address, 'street_number'), 'name' => self::getArrayValueFromKeyOrNull($address, 'street_name')];
     $country = ['name' => self::getArrayValueFromKeyOrNull($address, 'country_name'), 'code' => self::getArrayValueFromKeyOrNull($address, 'country_code'), 'continent' => self::getArrayValueFromKeyOrNull($address, 'continent')];
     $coordinates = ['latitude' => self::getArrayValueFromKeyOrNull($address, 'latitude'), 'longitude' => self::getArrayValueFromKeyOrNull($address, 'longitude'), 'elevation' => self::getArrayValueFromKeyOrNull($address, 'elevation')];
     return new AddressValueObject(Assembler\Street::fromArray($street), self::getArrayValueFromKeyOrNull($address, 'city'), self::getArrayValueFromKeyOrNull($address, 'postalcode'), self::getArrayValueFromKeyOrNull($address, 'region'), Assembler\Country::fromArray($country), Assembler\Coordinates::fromArray($coordinates));
 }
Ejemplo n.º 2
0
 public function testFromArray($inputArray, $expectedResult)
 {
     $this->given($street = TestedStreetAssembler::fromArray($inputArray))->string($street->__toString())->isIdenticalTo($expectedResult);
 }