Exemple #1
0
 /**
  * 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;
 }
Exemple #2
0
 /**
  * Compares two units
  *
  * @param  Zend_Measure_Abstract $object object of same unit type
  * @return boolean
  */
 public function compare($object)
 {
     $object->setType($this->getType());
     $value = $this->getValue(-1) - $object->getValue(-1);
     if ($value < 0) {
         return -1;
     } else {
         if ($value > 0) {
             return 1;
         }
     }
     return 0;
 }
Exemple #3
0
 /**
  * Returns a string representation
  *
  * @return string
  */
 public function toString()
 {
     return parent::getValue() . ' ' . self::$_UNITS[parent::getType()][1];
 }
Exemple #4
0
 /**
  * Returns a string representation
  *
  * @return string
  */
 public function toString()
 {
     return parent::getValue();
 }