예제 #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));
 }
예제 #2
0
 public function testFromArray($inputArray, $expectedResult)
 {
     $this->given($country = TestedCountryAssembler::fromArray($inputArray))->string($country->__toString())->isIdenticalTo($expectedResult);
 }