예제 #1
0
 /**
  * (Required) Country code.
  * Character length and limitations: 2 single-byte characters
  *
  * @param $country
  * @throws Exception
  */
 public function setCountry($country)
 {
     if (strlen($country) > 2) {
         $country = CountryCodes::getCodeByName($country);
     }
     if (!CountryCodes::isValid($country)) {
         /*
          * @todo create Exception class for InvalidCountry
          */
         throw new \Exception('Invalid country specified in ' . get_class($this));
     }
     $this->setCountryCode($country);
     return $this;
 }
예제 #2
0
 public function testCanGetCodeByCountryName()
 {
     $this->assertEquals(CountryCodes::getCodeByName('United States'), 'US');
 }