/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }