Esempio n. 1
0
 /**
  * Constructor
  *
  * @author Tom Haskins-Vaughan <*****@*****.**>
  * @since  0.3.0
  *
  * @param Fraction $amount
  * @param Unit     $unit
  *
  * @throws \Quantity\InvalidAmountException
  */
 public function __construct(Fraction $amount, Uom $uom)
 {
     $reflection = new \ReflectionClass($this);
     $subClassName = $reflection->getShortName();
     $uoms = Uom::getUoms();
     // check that the given Uom belongs to the given sub class
     if (!array_key_exists($uom->getName(), $uoms[$subClassName])) {
         throw new InvalidUomException($uom->getName());
     }
     $this->amount = $amount;
     $this->uom = $uom;
 }
Esempio n. 2
0
 /**
  * Whether this Uom is equivalent to another
  *
  * @author Tom Haskins-Vaughan <*****@*****.**>
  * @since  0.10.0
  *
  * @param Uom $other
  *
  * @return bool
  */
 public function isSameValueAs(Uom $other)
 {
     return $this->getName() === $other->getName();
 }