Inheritance: implements ValueObjects\ValueObjectInterface
コード例 #1
0
ファイル: Address.php プロジェクト: cermat/valueobjects
 /**
  * Returns a new Address from native PHP arguments
  *
  * @param string $name
  * @param string $street_name
  * @param string $street_number
  * @param string $district
  * @param string $city
  * @param string $region
  * @param string $postal_code
  * @param string $country_code
  * @return self
  * @throws \BadMethodCallException
  */
 public static function fromNative()
 {
     $args = \func_get_args();
     if (\count($args) != 8) {
         throw new \BadMethodCallException('You must provide exactly 8 arguments: 1) addressee name, 2) street name, 3) street number, 4) district, 5) city, 6) region, 7) postal code, 8) country code.');
     }
     $name = new StringLiteral($args[0]);
     $street = new Street(new StringLiteral($args[1]), new StringLiteral($args[2]));
     $district = new StringLiteral($args[3]);
     $city = new StringLiteral($args[4]);
     $region = new StringLiteral($args[5]);
     $postalCode = new StringLiteral($args[6]);
     $country = Country::fromNative($args[7]);
     return new self($name, $street, $district, $city, $region, $postalCode, $country);
 }
コード例 #2
0
ファイル: CountryTest.php プロジェクト: cermat/valueobjects
 public function testToString()
 {
     $italy = new Country(CountryCode::IT());
     $this->assertSame('Italy', $italy->__toString());
 }