Exemplo n.º 1
0
 /**
  * @covers MeasureUtils::getUnitInfo
  * @todo Implement testGetUnitInfo().
  */
 public function testGetUnitInfo()
 {
     $actual = \MeasureUtils::getUnitInfo('Zend_Measure_Temperature::CELSIUS');
     $excepted = array('className' => 'Zend_Measure_Temperature', 'constantName' => 'CELSIUS');
     $this->assertEquals($excepted, $actual);
 }
Exemplo n.º 2
0
 /**
  * @return String
  */
 private function getUnitSymbol()
 {
     $unit = $this->displayUnit;
     // Get symbol from unit name
     $zendMeasureObj = MeasureUtils::newMeasure($unit);
     $convList = $zendMeasureObj->getConversionList();
     return $convList[$zendMeasureObj->getType()][1];
 }
Exemplo n.º 3
0
 /**
  * Get a measure object.
  * The measure object is constructed using the value and the unit should
  * be available in the map.
  *
  * @param $map
  * @param $key
  * @return Zend_Measure_Abstract
  */
 public function getMeasure($map, $key)
 {
     $value = $this->getValue($map, $key);
     if (!isset($value) || $value === "" || $value === false) {
         return null;
     }
     $unitValue = $this->getValue($map, $key . '__unit');
     if (!$unitValue) {
         throw new IllegalArgumentException("The map should contain the unit");
     }
     return MeasureUtils::newMeasure($unitValue, $this->formatter->getNumber($value));
 }