/** * @covers MeasureUtils::newMeasure */ public function testNewMeasure() { $measure = \MeasureUtils::newMeasure('Zend_Measure_Weight::TON'); $this->assertInstanceOf("Zend_Measure_Weight", $measure); }
/** * @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]; }
/** * 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)); }