Example #1
0
 public function testToString()
 {
     $volume = new Volume(3);
     $this->assertEquals('3l', $volume->__toString());
 }
 /**
  * Calculate the effects of adding a compound.
  *
  * Returns a solution object where the water in the tank is the solvent and
  * the added compound is the solute.
  *
  * @param CompoundInterface $compound Compound added.
  *
  * @return Solution Tank water as a solution.
  */
 public function effectsOf(CompoundInterface $compound)
 {
     return new Solution($compound, new Volume($this->volume->toUnit() + $compound->getVolume()->toUnit()));
 }
 /**
  * Gets wet compound dose by name and quantity.
  *
  * @param string $compoundId Wet compound name.
  * @param Volume $volume Quantity of the compound.
  *
  * @return Solution Solution object.
  */
 public function getWetCompound($compoundId, Volume $volume = null)
 {
     if (!array_key_exists($compoundId, $this->data['wetCompounds'])) {
         return null;
     }
     if ($volume === null) {
         $volume = new Volume(1);
     }
     $compound = new Compound($this->data['wetCompounds'][$compoundId], new Mass($volume->toUnit('l')));
     return new Solution($compound, $volume);
 }