Ejemplo n.º 1
0
 public static function getDividedUnit(Quantity $numerator, Quantity $denominator)
 {
     $unitComp = [];
     foreach ($numerator->getUnitsPresent() as $unitType => $unitCount) {
         if ($unitCount != 0) {
             $unitComp[$unitType] += $unitCount;
         }
     }
     foreach ($denominator->getUnitsPresent() as $unitType => $unitCount) {
         if ($unitCount != 0) {
             $unitComp[$unitType] -= $unitCount;
         }
     }
     return self::getUnitCompClass($unitComp);
 }
Ejemplo n.º 2
0
 public function __construct($value, $unit = null)
 {
     $this->rates = [$this->units[self::MILLISECOND] => '0.001', $this->units[self::SECOND] => '1', $this->units[self::MINUTE] => '60', $this->units[self::HOUR] => '3600', $this->units[self::DAY] => '86400', $this->units[self::WEEK] => '604800', $this->units[self::YEAR] => '31556736'];
     $this->unitTypesPresent = UnitComposition::$unitComp[UnitComposition::TIME];
     parent::__construct($value, $unit);
 }
Ejemplo n.º 3
0
 public function __construct($quantity, $unit = null)
 {
     $this->rates = [$this->units[self::MILLIMETER] => '0.001', $this->units[self::CENTIMETER] => '0.01', $this->units[self::METER] => '1', $this->units[self::KILOMETER] => '1000', $this->units[self::INCH] => '0.0254', $this->units[self::FOOT] => '0.3048', $this->units[self::YARD] => '0.9144', $this->units[self::MILE] => '1609.34', $this->units[self::NAUTICAL_MILE] => '1852', $this->units[self::ASTRONOMICAL_UNIT] => '149597870700', $this->units[self::LIGHT_YEAR] => '9460528400000000'];
     $this->unitTypesPresent = UnitComposition::$unitComp[UnitComposition::LENGTH];
     parent::__construct($quantity, $unit);
 }
Ejemplo n.º 4
0
 public function __construct($value, $unit = null)
 {
     $this->rates = [$this->units[self::JOULE] => '1', $this->units[self::KILOWATTHOUR] => '3600'];
     $this->unitTypesPresent = UnitComposition::$unitComp[UnitComposition::ENERGY];
     parent::__construct($value, $unit);
 }
Ejemplo n.º 5
0
 public function __construct($value, $unit = null)
 {
     $this->rates = [$this->units[self::METERS_PER_SECOND] => '1', $this->units[self::KILOMETERS_PER_SECOND] => '1000', $this->units[self::LIGHT_SPEED] => '299792458', $this->units[self::AU_PER_SECOND] => '149597870700'];
     $this->unitTypesPresent = UnitComposition::$unitComp[UnitComposition::VELOCITY];
     parent::__construct($value, $unit);
 }
Ejemplo n.º 6
0
 public function __construct($value, $unit = null)
 {
     $this->rates = [$this->units[self::KG_PER_CUBIC_METER] => '1', $this->units[self::G_PER_CUBIC_CENTIMETER] => '0.001'];
     $this->unitTypesPresent = UnitComposition::$unitComp[UnitComposition::DENSITY];
     parent::__construct($value, $unit);
 }
Ejemplo n.º 7
0
 public function __construct($value, $unit = null)
 {
     $this->rates = [$this->units[self::VOLTS] => '1', $this->units[self::KILOVOLTS] => '1000', $this->units[self::MEGAVOLTS] => '1000000', $this->units[self::GIGAVOLTS] => '1000000000', $this->units[self::TERRAVOLTS] => '1000000000000'];
     $this->unitTypesPresent = UnitComposition::$unitComp[UnitComposition::VOLTAGE];
     parent::__construct($value, $unit);
 }
Ejemplo n.º 8
0
 public function __construct($value, $unit = null)
 {
     $this->rates = [$this->units[self::EWARKS] => '1', $this->units[self::KILOEWARKS] => '1000', $this->units[self::MEGAEWARKS] => '1000000', $this->units[self::GIGAEWARKS] => '1000000000'];
     $this->unitTypesPresent = UnitComposition::$unitComp[UnitComposition::WARPFIELD];
     parent::__construct($value, $unit);
 }
Ejemplo n.º 9
0
 public function __construct($value, $unit = null)
 {
     $this->rates = [$this->units[self::SQUARE_METER] => '1', $this->units[self::HECTARE] => '100', $this->units[self::SQUARE_KILOMETER] => '1000000', $this->units[self::SQUARE_INCH] => '0.00064516', $this->units[self::SQUARE_FEET] => '0.09290304', $this->units[self::SQUARE_YARD] => '0.83612736', $this->units[self::ACRE] => '247.105', $this->units[self::SQUARE_MILE] => '2589988.110336'];
     $this->unitTypesPresent = UnitComposition::$unitComp[UnitComposition::AREA];
     parent::__construct($value, $unit);
 }
Ejemplo n.º 10
0
 public function __construct($value, $unit = null)
 {
     $this->rates = [$this->units[self::WATT] => '1', $this->units[self::KILOWATT] => '1000', $this->units[self::MEGAWATT] => '1000000', $this->units[self::GIGAWATT] => '1000000000', $this->units[self::TERAWATT] => '1000000000000', $this->units[self::PETAWATT] => '1000000000000000', $this->units[self::HORSEPOWER] => '745.699872'];
     $this->unitTypesPresent = UnitComposition::$unitComp[UnitComposition::POWER];
     parent::__construct($value, $unit);
 }
Ejemplo n.º 11
0
 public function __construct($value, $unit = null)
 {
     $this->rates = [$this->units[self::PASCAL] => '1', $this->units[self::KILOPASCAL] => '1000', $this->units[self::MEGAPASCAL] => '1000000', $this->units[self::GIGAPASCAL] => '1000000000', $this->units[self::TERAPASCAL] => '1000000000000', $this->units[self::BAR] => '100000', $this->units[self::TORR] => '133.3224', $this->units[self::ATMOSPHERE] => '101325', $this->units[self::PSI] => '6894.8'];
     $this->unitTypesPresent = UnitComposition::$unitComp[UnitComposition::PRESSURE];
     parent::__construct($value, $unit);
 }
Ejemplo n.º 12
0
 public function __construct($value, $unit = null)
 {
     $this->rates = [$this->units[self::CUBIC_METERS] => '1', $this->units[self::CUBIC_KILOMETERS] => '1000000000', $this->units[self::LITERS] => '0.001', $this->units[self::GALLONS] => '0.00378541'];
     $this->unitTypesPresent = UnitComposition::$unitComp[UnitComposition::VOLUME];
     parent::__construct($value, $unit);
 }
Ejemplo n.º 13
0
 public function __construct($value, $unit = null)
 {
     $this->rates = [$this->units[self::AMPERE] => '1', $this->units[self::KILOAMPERE] => '1000', $this->units[self::MEGAAMPERE] => '1000000'];
     $this->unitTypesPresent = UnitComposition::$unitComp[UnitComposition::AMPERE];
     parent::__construct($value, $unit);
 }
Ejemplo n.º 14
0
 public function __construct($value, $unit = null)
 {
     $this->rates = [$this->units[self::MICROGRAM] => '0.000000001', $this->units[self::MILLIGRAM] => '0.000001', $this->units[self::GRAM] => '0.001', $this->units[self::KILOGRAM] => '1', $this->units[self::METRIC_TON] => '100'];
     $this->unitTypesPresent = UnitComposition::$unitComp[UnitComposition::MASS];
     parent::__construct($value, $unit);
 }
Ejemplo n.º 15
0
 public function __construct($value, $unit = null)
 {
     $this->rates = [$this->units[self::METERS_PER_SECOND_SQUARED] => '1'];
     $this->unitTypesPresent = UnitComposition::$unitComp[UnitComposition::ACCELERATION];
     parent::__construct($value, $unit);
 }
Ejemplo n.º 16
0
 public function __construct($value, $unit = null)
 {
     $this->rates = [$this->units[self::COULOMB] => '1', $this->units[self::KILOCOULOMB] => '1000'];
     $this->unitTypesPresent = UnitComposition::$unitComp[UnitComposition::CHARGE];
     parent::__construct($value, $unit);
 }