/**
  * Convert data in standard unit for metrics
  *
  * @param Metric $metric
  */
 protected function createMetricBaseValues(Metric $metric)
 {
     $baseUnit = $this->manager->getStandardUnitForFamily($metric->getFamily());
     if (is_numeric($metric->getData())) {
         $baseData = $this->converter->setFamily($metric->getFamily())->convertBaseToStandard($metric->getUnit(), $metric->getData());
     } else {
         $baseData = null;
     }
     $metric->setBaseData($baseData);
     $metric->setBaseUnit($baseUnit);
 }
 function it_normalizes_a_metric_into_mongodb_document($mongoFactory, $converter, $manager, Metric $metric, \MongoId $mongoId)
 {
     $mongoFactory->createMongoId()->willReturn($mongoId);
     $metric->getUnit()->willReturn('Kg');
     $metric->getData()->willReturn(85);
     $metric->getFamily()->willReturn('weight');
     $converter->setFamily('weight')->willReturn($converter);
     $converter->convertBaseToStandard('Kg', 85)->willReturn(8500);
     $manager->getStandardUnitForFamily('weight')->willReturn('g');
     $metric->setBaseData(8500)->shouldBeCalled();
     $metric->getBaseData()->willReturn(8500);
     $metric->setBaseUnit('g')->shouldBeCalled();
     $metric->getBaseUnit()->willReturn('g');
     $this->normalize($metric, 'mongodb_document')->shouldReturn(['_id' => $mongoId, 'unit' => 'Kg', 'data' => 85, 'baseUnit' => 'g', 'baseData' => 8500, 'family' => 'weight']);
 }
 /**
  * {@inheritDoc}
  */
 public function getFamily()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getFamily', array());
     return parent::getFamily();
 }