for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* PHP Units of Measure Library
*
* @link https://github.com/hiqdev/php-units
* @package php-units
* @license BSD-3-Clause
* @copyright Copyright (c) 2017, HiQDev (http://hiqdev.com/)
*/
namespace hiqdev\php\units\calculators;
use hiqdev\php\units\CalculatorInterface;
* @author Andrii Vasyliev <[email protected]>
class PhpCalculator implements CalculatorInterface
{
* {@inheritdoc}
public static function isSupported()
return true;
}
public function compare($a, $b)
return ($a < $b) ? -1 : (($a > $b) ? 1 : 0);
public function add($amount, $addend)
$result = $amount + $addend;
return $result;
public function subtract($amount, $subtrahend)
$result = $amount - $subtrahend;
public function multiply($amount, $multiplier)
$result = $amount * $multiplier;
public function divide($amount, $divisor)
$result = $amount / $divisor;
public function ceil($number)
return ceil($number);
public function floor($number)
return floor($number);
public function absolute($number)
throw new \Exception();
public function round($number, $roundingMode)