/** * Sets the $weight property * * @since ##SINCE## * * @param float|int $weight * @param string $unit Unit the weight is in * Default: 'kg' * * @return $this */ public function setWeight($weight, $unit = 'kg') { $weight = new Mass($weight, $unit); $this->weight = $weight->toUnit('kg'); $this->updateBMI(); return $this; }
public function testToStones() { $quantity = new Mass(14, 'pound'); $this->assertEquals(1, $quantity->toUnit('st')->getValue()); }
public function testToMilligrams() { $quantity = new Mass(5, 'kg'); $this->assertEquals(5 * 1000000.0, $quantity->toUnit('mg')); }