コード例 #1
0
ファイル: PostCode.php プロジェクト: DanMaiman/Awfulkid
 /**
  * Sets the locale to use
  *
  * @param string|Postman_Zend_Locale $locale
  * @throws Postman_Zend_Validate_Exception On unrecognised region
  * @throws Postman_Zend_Validate_Exception On not detected format
  * @return Postman_Zend_Validate_PostCode  Provides a fluent interface
  */
 public function setLocale($locale = null)
 {
     require_once 'Zend/Locale.php';
     $this->_locale = Postman_Zend_Locale::findLocale($locale);
     $locale = new Postman_Zend_Locale($this->_locale);
     $region = $locale->getRegion();
     if (empty($region)) {
         require_once 'Zend/Validate/Exception.php';
         throw new Postman_Zend_Validate_Exception("Unable to detect a region for the locale '{$locale}'");
     }
     $format = Postman_Zend_Locale::getTranslation($locale->getRegion(), 'postaltoterritory', $this->_locale);
     if (empty($format)) {
         require_once 'Zend/Validate/Exception.php';
         throw new Postman_Zend_Validate_Exception("Unable to detect a postcode format for the region '{$locale->getRegion()}'");
     }
     $this->setFormat($format);
     return $this;
 }
コード例 #2
0
ファイル: Date.php プロジェクト: DanMaiman/Awfulkid
 /**
  * Sets the locale option
  *
  * @param  string|Postman_Zend_Locale $locale
  * @return Postman_Zend_Validate_Date provides a fluent interface
  */
 public function setLocale($locale = null)
 {
     require_once 'Zend/Locale.php';
     $this->_locale = Postman_Zend_Locale::findLocale($locale);
     return $this;
 }
コード例 #3
0
ファイル: Iban.php プロジェクト: DanMaiman/Awfulkid
 /**
  * Sets the locale option
  *
  * @param  string|Postman_Zend_Locale $locale
  * @throws Postman_Zend_Locale_Exception
  * @throws Postman_Zend_Validate_Exception
  * @return Postman_Zend_Validate_Date provides a fluent interface
  */
 public function setLocale($locale = null)
 {
     if ($locale !== false) {
         require_once 'Zend/Locale.php';
         $locale = Postman_Zend_Locale::findLocale($locale);
         if (strlen($locale) < 4) {
             require_once 'Zend/Validate/Exception.php';
             throw new Postman_Zend_Validate_Exception('Region must be given for IBAN validation');
         }
     }
     $this->_locale = $locale;
     return $this;
 }