コード例 #1
0
ファイル: Measure.php プロジェクト: hssh/ZendEx
 /**
  * Defined by Zend_Filter_Interface
  *
  * Returns the numerical value, from measure string
  *
  * @param  string $value
  * @return integer|string
  */
 public function filter($value)
 {
     $locale = $this->_measure->getLocale();
     $matched = false;
     foreach ($this->_measure->getConversionList() as $key => $conversion) {
         if (preg_match("~^(.*)" . $conversion[1] . "\$~", $value, $matches)) {
             try {
                 // $number = Zend_Locale_Format::getNumber(trim($matches[1]), array('locale' => $locale));
                 $this->_measure->setType($key)->setValue(trim($matches[1]));
             } catch (Exception $e) {
                 continue;
             }
             $matched = true;
         }
     }
     return $matched ? $this->_measure->getValue() : $value;
 }