当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Measure_Abstract::setType方法代码示例

本文整理汇总了PHP中Zend_Measure_Abstract::setType方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Measure_Abstract::setType方法的具体用法?PHP Zend_Measure_Abstract::setType怎么用?PHP Zend_Measure_Abstract::setType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Measure_Abstract的用法示例。


在下文中一共展示了Zend_Measure_Abstract::setType方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: filter

 /**
  * 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;
 }
开发者ID:hssh,项目名称:ZendEx,代码行数:25,代码来源:Measure.php

示例2: setType

 /**
  * Set a new type, and convert the value
  *
  * @param  string  $type  New type to set
  * @throws Zend_Measure_Exception
  */
 public function setType($type)
 {
     if (empty(self::$_UNITS[$type])) {
         throw new Zend_Measure_Exception("type ({$type}) is a unknown flow mass");
     }
     // Convert to standard value
     $value = parent::getValue();
     if (is_array(self::$_UNITS[parent::getType()][0])) {
         foreach (self::$_UNITS[parent::getType()][0] as $key => $found) {
             switch ($key) {
                 case "/":
                     $value /= $found;
                     break;
                 default:
                     $value *= $found;
                     break;
             }
         }
     } else {
         $value = $value * self::$_UNITS[parent::getType()][0];
     }
     // Convert to expected value
     if (is_array(self::$_UNITS[$type][0])) {
         foreach (self::$_UNITS[$type][0] as $key => $found) {
             switch ($key) {
                 case "/":
                     $value *= $found;
                     break;
                 default:
                     $value /= $found;
                     break;
             }
         }
     } else {
         $value = $value / self::$_UNITS[$type][0];
     }
     parent::setValue($value, $type, $this->_Locale);
     parent::setType($type);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:45,代码来源:Mass.php

示例3: setType

 /**
  * Set a new type, and convert the value
  *
  * @param $type  new type to set
  * @throws Zend_Measure_Exception
  */
 public function setType($type)
 {
     if (empty(self::$_UNITS[$type])) {
         throw Zend::exception('Zend_Measure_Exception', 'unknown type of number:' . $type);
     }
     $value = $this->toDecimal(parent::getValue(), parent::getType());
     $value = $this->fromDecimal($value, $type);
     parent::setValue($value, $type, $this->_Locale);
     parent::setType($type);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:16,代码来源:Number.php

示例4: compare

 /**
  * 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;
 }
开发者ID:be-dmitry,项目名称:zf1,代码行数:19,代码来源:Abstract.php

示例5: setType

 /**
  * Set a new type, and convert the value
  *
  * @param  string  $type  New type to set
  * @throws Zend_Measure_Exception
  */
 public function setType($type)
 {
     if (empty(self::$_UNITS[$type])) {
         throw new Zend_Measure_Exception("type ({$type}) is a unknown illumination");
     }
     // Convert to standard value
     $value = parent::getValue();
     $value = $value * self::$_UNITS[parent::getType()][0];
     // Convert to expected value
     $value = $value / self::$_UNITS[$type][0];
     parent::setValue($value, $type, $this->_Locale);
     parent::setType($type);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:19,代码来源:Illumination.php

示例6: setType

 /**
  * Set a new type, and convert the value
  *
  * @param  $type  type to set
  * @throws Zend_Measure_Exception
  */
 public function setType($type)
 {
     if (empty(self::$_UNITS[$type])) {
         self::throwException('unknown type of lightness:' . $type);
     }
     // Convert to standard value
     $value = parent::getValue();
     $value = $value * self::$_UNITS[parent::getType()][0];
     // Convert to expected value
     $value = $value / self::$_UNITS[$type][0];
     parent::setValue($value, $type, $this->_Locale);
     parent::setType($type);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:19,代码来源:Lightness.php

示例7: setType

 /**
  * Set a new type, and convert the value
  *
  * @throws Zend_Measure_Exception
  */
 public function setType($type)
 {
     if (empty(self::$_UNITS[$type])) {
         throw Zend::exception('Zend_Measure_Exception', 'unknown type of force:' . $type);
     }
     // Convert to standard value
     $value = parent::getValue();
     $value = $value * self::$_UNITS[parent::getType()][0];
     // Convert to expected value
     $value = $value / self::$_UNITS[$type][0];
     parent::setValue($value, $type, $this->_Locale);
     parent::setType($type);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:18,代码来源:Force.php

示例8: setType

 /**
  * Set a new type, and convert the value
  *
  * @param $type  new type to set
  * @throws Zend_Measure_Exception
  */
 public function setType($type)
 {
     if (empty(self::$_UNITS[$type])) {
         self::throwException('unknown type of kinematic viscosity:' . $type);
     }
     // Convert to standard value
     $value = parent::getValue();
     if (is_array(self::$_UNITS[parent::getType()][0])) {
         foreach (self::$_UNITS[parent::getType()][0] as $key => $found) {
             switch ($key) {
                 case "/":
                     $value /= $found;
                     break;
                 default:
                     $value *= $found;
                     break;
             }
         }
     } else {
         $value = $value * self::$_UNITS[parent::getType()][0];
     }
     // Convert to expected value
     if (is_array(self::$_UNITS[$type][0])) {
         foreach (self::$_UNITS[$type][0] as $key => $found) {
             switch ($key) {
                 case "/":
                     $value *= $found;
                     break;
                 default:
                     $value /= $found;
                     break;
             }
         }
     } else {
         $value = $value / self::$_UNITS[$type][0];
     }
     parent::setValue($value, $type, $this->_Locale);
     parent::setType($type);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:45,代码来源:Kinematic.php

示例9: setType

 /**
  * Set a new type, and convert the value
  *
  * @param $type  new type to set
  * @throws Zend_Measure_Exception
  */
 public function setType($type)
 {
     if (empty(self::$_UNITS[$type])) {
         self::throwException('unknown type of binary:' . $type);
     }
     // Convert to standard value
     $value = parent::getValue();
     $value = bcmul($value, self::$_UNITS[parent::getType()][0], 25);
     // Convert to expected value
     $value = bcdiv($value, self::$_UNITS[$type][0]);
     parent::setValue($value, $type, $this->_Locale);
     parent::setType($type);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:19,代码来源:Binary.php

示例10: setType

 /**
  * Set a new type, and convert the value
  *
  * @param $type new type to set
  * @throws Zend_Measure_Exception
  */
 public function setType($type)
 {
     if (empty(self::$_UNITS[$type])) {
         throw Zend::exception('Zend_Measure_Exception', 'unknown type of temperature:' . $type);
     }
     // Convert to standard value
     $value = parent::getValue();
     if (is_array(self::$_UNITS[parent::getType()][0])) {
         foreach (self::$_UNITS[parent::getType()][0] as $key => $found) {
             switch ($key) {
                 case "/":
                     $value /= $found;
                     break;
                 case "+":
                     $value += $found;
                     break;
                 case "-":
                     $value -= $found;
                     break;
                 default:
                     $value *= $found;
                     break;
             }
         }
     } else {
         $value = $value * self::$_UNITS[parent::getType()][0];
     }
     // Convert to expected value
     if (is_array(self::$_UNITS[$type][0])) {
         foreach (self::$_UNITS[$type][0] as $key => $found) {
             switch ($key) {
                 case "/":
                     $value *= $found;
                     break;
                 case "+":
                     $value -= $found;
                     break;
                 case "-":
                     $value += $found;
                     break;
                 default:
                     $value /= $found;
                     break;
             }
         }
     } else {
         $value = $value / self::$_UNITS[$type][0];
     }
     parent::setValue($value, $type, $this->_Locale);
     parent::setType($type);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:57,代码来源:Temperature.php

示例11: setType

 /**
  * Set a new type, and convert the value
  *
  * @param  string  $type  New type to set
  * @throws Zend_Measure_Exception
  */
 public function setType($type)
 {
     if (empty(self::$_UNITS[$type])) {
         throw new Zend_Measure_Exception("type ({$type}) is a unknown binary");
     }
     // Convert to standard value
     $value = parent::getValue();
     $value = call_user_func(Zend_Locale_Math::$mul, $value, self::$_UNITS[parent::getType()][0], 25);
     // Convert to expected value
     $value = call_user_func(Zend_Locale_Math::$div, $value, self::$_UNITS[$type][0]);
     parent::setValue($value, $type, $this->_Locale);
     parent::setType($type);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:19,代码来源:Binary.php


注:本文中的Zend_Measure_Abstract::setType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。