/** * (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; }
public function testCodeToNameArray() { $countries = CountryCodes::getCodeToNameArray(); $this->assertEquals($countries['US'], 'UNITED STATES'); }