From 9118f1e283ff68143726d23c5bd2ff3de2404209 Mon Sep 17 00:00:00 2001 From: jordanbrauer Date: Mon, 13 Nov 2017 12:12:57 -0600 Subject: [PATCH] Fix: formatting & docblocks --- .editorconfig | 12 + .../Calculator/AbstractCalculator.php | 191 ++++---- .../Calculator/BinaryCalculator.php | 80 ++-- .../Calculator/CalculatorInterface.php | 155 ++++--- .../Calculator/SimpleCalculator.php | 121 ++--- .../Exception/MissingCalculatorException.php | 8 +- .../MissingUnitRegistryException.php | 8 +- .../UnknownMeasurementTypeException.php | 8 +- .../UnknownUnitOfMeasureException.php | 8 +- src/UnitConverter/Measure.php | 24 +- src/UnitConverter/Registry/UnitRegistry.php | 225 +++++----- .../Registry/UnitRegistryInterface.php | 236 +++++----- src/UnitConverter/Unit/AbstractUnit.php | 290 ++++++------ src/UnitConverter/Unit/Area/Acre.php | 22 +- src/UnitConverter/Unit/Area/AreaUnit.php | 8 +- src/UnitConverter/Unit/Area/Hectare.php | 20 +- .../Unit/Area/SquareCentimeter.php | 20 +- src/UnitConverter/Unit/Area/SquareFoot.php | 20 +- .../Unit/Area/SquareKilometer.php | 20 +- src/UnitConverter/Unit/Area/SquareMeter.php | 20 +- src/UnitConverter/Unit/Area/SquareMile.php | 22 +- .../Unit/Area/SquareMillimeter.php | 20 +- src/UnitConverter/Unit/Energy/Calorie.php | 20 +- src/UnitConverter/Unit/Energy/EnergyUnit.php | 8 +- src/UnitConverter/Unit/Energy/FootPound.php | 20 +- src/UnitConverter/Unit/Energy/Joule.php | 20 +- src/UnitConverter/Unit/Energy/Kilojoule.php | 20 +- .../Unit/Energy/KilowattHour.php | 20 +- .../Unit/Energy/Megaelectronvolt.php | 20 +- src/UnitConverter/Unit/Energy/Megajoule.php | 20 +- .../Unit/Energy/MegawattHour.php | 20 +- src/UnitConverter/Unit/Energy/NewtonMeter.php | 20 +- src/UnitConverter/Unit/Energy/WattHour.php | 20 +- .../Unit/Length/AstronomicalUnit.php | 20 +- src/UnitConverter/Unit/Length/Centimeter.php | 20 +- src/UnitConverter/Unit/Length/Decimeter.php | 20 +- src/UnitConverter/Unit/Length/Foot.php | 20 +- src/UnitConverter/Unit/Length/Hand.php | 20 +- src/UnitConverter/Unit/Length/Inch.php | 20 +- src/UnitConverter/Unit/Length/Kilometer.php | 20 +- src/UnitConverter/Unit/Length/LengthUnit.php | 8 +- src/UnitConverter/Unit/Length/Lightyear.php | 24 +- src/UnitConverter/Unit/Length/Meter.php | 20 +- src/UnitConverter/Unit/Length/Micrometer.php | 22 +- src/UnitConverter/Unit/Length/Mile.php | 20 +- src/UnitConverter/Unit/Length/Milimeter.php | 20 +- src/UnitConverter/Unit/Length/Nanometer.php | 22 +- src/UnitConverter/Unit/Length/Parsec.php | 26 +- src/UnitConverter/Unit/Length/Picometer.php | 22 +- src/UnitConverter/Unit/Length/Yard.php | 20 +- src/UnitConverter/Unit/Mass/Gram.php | 20 +- src/UnitConverter/Unit/Mass/Kilogram.php | 20 +- src/UnitConverter/Unit/Mass/MassUnit.php | 8 +- src/UnitConverter/Unit/Mass/MetricTonne.php | 20 +- src/UnitConverter/Unit/Mass/Milligram.php | 20 +- src/UnitConverter/Unit/Mass/Newton.php | 20 +- src/UnitConverter/Unit/Mass/Ounce.php | 20 +- src/UnitConverter/Unit/Mass/Pound.php | 20 +- src/UnitConverter/Unit/Mass/Stone.php | 10 +- src/UnitConverter/Unit/Mass/UKLongTon.php | 10 +- src/UnitConverter/Unit/Mass/USShortTon.php | 10 +- src/UnitConverter/Unit/PlaneAngle/Degree.php | 20 +- .../Unit/PlaneAngle/PlaneAngleUnit.php | 8 +- src/UnitConverter/Unit/PlaneAngle/Radian.php | 20 +- .../Unit/Pressure/Atmosphere.php | 20 +- src/UnitConverter/Unit/Pressure/Bar.php | 20 +- .../Unit/Pressure/Kilopascal.php | 22 +- .../Unit/Pressure/Megapascal.php | 22 +- src/UnitConverter/Unit/Pressure/Millibar.php | 8 +- src/UnitConverter/Unit/Pressure/Pascal.php | 20 +- .../Unit/Pressure/PoundForcePerSquareInch.php | 20 +- .../Unit/Pressure/PressureUnit.php | 6 +- src/UnitConverter/Unit/Pressure/Torr.php | 18 +- .../Unit/Speed/KilometrePerHour.php | 20 +- .../Unit/Speed/MetrePerSecond.php | 20 +- src/UnitConverter/Unit/Speed/MilesPerHour.php | 20 +- src/UnitConverter/Unit/Speed/SpeedUnit.php | 8 +- .../Unit/Temperature/Celsius.php | 72 +-- .../Unit/Temperature/Fahrenheit.php | 78 ++-- src/UnitConverter/Unit/Temperature/Kelvin.php | 20 +- .../Unit/Temperature/TemperatureUnit.php | 8 +- src/UnitConverter/Unit/Time/Day.php | 8 +- src/UnitConverter/Unit/Time/Hour.php | 8 +- src/UnitConverter/Unit/Time/Microsecond.php | 8 +- src/UnitConverter/Unit/Time/Millisecond.php | 8 +- src/UnitConverter/Unit/Time/Minute.php | 8 +- src/UnitConverter/Unit/Time/Month.php | 8 +- src/UnitConverter/Unit/Time/Nanosecond.php | 8 +- src/UnitConverter/Unit/Time/Second.php | 8 +- src/UnitConverter/Unit/Time/TimeUnit.php | 6 +- src/UnitConverter/Unit/Time/Week.php | 8 +- src/UnitConverter/Unit/Time/Year.php | 8 +- src/UnitConverter/Unit/UnitInterface.php | 200 ++++----- src/UnitConverter/Unit/Volume/CubicMetre.php | 20 +- src/UnitConverter/Unit/Volume/Gallon.php | 20 +- src/UnitConverter/Unit/Volume/Litre.php | 20 +- src/UnitConverter/Unit/Volume/Mililitre.php | 20 +- src/UnitConverter/Unit/Volume/Pint.php | 20 +- src/UnitConverter/Unit/Volume/VolumeUnit.php | 8 +- src/UnitConverter/UnitConverter.php | 362 +++++++-------- src/UnitConverter/UnitConverterInterface.php | 70 +-- .../Unit/Energy/EnergyUnits.spec.php | 66 ++- .../Unit/Pressure/PressureUnits.spec.php | 76 ++-- .../Temperature/TemperatureUnits.spec.php | 146 +++--- .../Unit/Volume/VolumeUnits.spec.php | 64 ++- .../Calculator/BinaryCalculator.spec.php | 176 ++++---- .../Calculator/SimpleCalculator.spec.php | 176 ++++---- .../Registry/UnitRegistry.spec.php | 415 +++++++++--------- .../UnitConverter/Unit/AbstractUnit.spec.php | 181 ++++---- .../unit/UnitConverter/UnitConverter.spec.php | 99 ++--- 110 files changed, 2487 insertions(+), 2456 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..56d3fa29 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 2 +indent_style = space +trim_trailing_whitespace = true +insert_final_newline = true + +[*.php] +indent_size = 4 diff --git a/src/UnitConverter/Calculator/AbstractCalculator.php b/src/UnitConverter/Calculator/AbstractCalculator.php index 1790ef12..9f35d1b8 100644 --- a/src/UnitConverter/Calculator/AbstractCalculator.php +++ b/src/UnitConverter/Calculator/AbstractCalculator.php @@ -10,13 +10,13 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Calculator; /** - * Internal math helper class for floating point decimal - * percision + * The abstract calculator class that all concrete calculators should + * extend from. * * @version 1.0.0 * @since 0.4.1 @@ -24,82 +24,111 @@ */ abstract class AbstractCalculator implements CalculatorInterface { - /** - * @var int $precision The number of decimal places that will calculated - */ - protected $precision; - - /** - * Public constructor for the unit converter calculator. - * - * @param int $precision The number of decimal places that will be calculated - */ - public function __construct (int $precision = 2) - { - $this->setPrecision($precision); - } - - public function setPrecision (int $precision): CalculatorInterface - { - $this->precision = $precision; - return $this; - } - - public function getPrecision (): int - { - return $this->precision; - } - - abstract public function add ($leftOperand, $rightOperand); - - abstract public function sub ($leftOperand, $rightOperand); - - abstract public function mul ($leftOperand, $rightOperand); - - abstract public function div ($dividend, $divisor); - - abstract public function mod ($dividend, $modulus); - - abstract public function pow ($base, $exponent); - - - /** - * Syntacital sugar wrapper method for sub - */ - public function subtract (...$params) - { - return $this->sub(...$params); - } - - /** - * Syntacital sugar wrapper method for mul - */ - public function multiply (...$params) - { - return $this->mul(...$params); - } - - /** - * Syntacital sugar wrapper method for div - */ - public function divide (...$params) - { - return $this->div(...$params); - } - - /** - * Syntacital sugar wrapper method for mod - */ - public function modulus (...$params) - { - return $this->mod(...$params); - } - - /** - * Syntacital sugar wrapper method for pow - */ - public function power (...$params) - { - return $this->pow(...$params); - } + /** + * @var int $precision The number of decimal places that will calculated + */ + protected $precision; + + /** + * @var int $roundingMode The mode in which rounding occurs. Use one of the PHP_ROUND_HALF_* constants. + */ + protected $roundingMode; + + /** + * Public constructor for the unit converter calculator. For a list of + * valid $roundingMode arguments, see the PHP_ROUND_HALF_* constants. + * + * @link https://secure.php.net/manual/en/function.round.php + * + * @param int $precision The number of decimal digits to round to. + * @param int $roundingMode The mode in which rounding occurs. + */ + public function __construct (int $precision = null, int $roundingMode = null) + { + $this->setPrecision(($precision ?? 2)); + $this->setRoundingMode(($roundingMode ?? PHP_ROUND_HALF_UP)); + } + + public function setPrecision (int $precision): CalculatorInterface + { + $this->precision = $precision; + return $this; + } + + public function setRoundingMode (int $roundingMode): CalculatorInterface + { + $this->roundingMode = $roundingMode; + return $this; + } + + public function getPrecision (): int + { + return $this->precision; + } + + public function getRoundingMode (): int + { + return $this->roundingMode; + } + + abstract public function add ($leftOperand, $rightOperand); + + abstract public function sub ($leftOperand, $rightOperand); + + abstract public function mul ($leftOperand, $rightOperand); + + abstract public function div ($dividend, $divisor); + + abstract public function mod ($dividend, $modulus); + + abstract public function pow ($base, $exponent); + + public function round ($value, int $precision = null): float + { + return round( + $value, + ($precision ?? $this->getPrecision()), + $this->getRoundingMode() + ); + } + + /** + * Syntacital sugar wrapper method for sub + */ + public function subtract (...$params) + { + return $this->sub(...$params); + } + + /** + * Syntacital sugar wrapper method for mul + */ + public function multiply (...$params) + { + return $this->mul(...$params); + } + + /** + * Syntacital sugar wrapper method for div + */ + public function divide (...$params) + { + return $this->div(...$params); + } + + /** + * Syntacital sugar wrapper method for mod + */ + public function modulus (...$params) + { + return $this->mod(...$params); + } + + /** + * Syntacital sugar wrapper method for pow + */ + public function power (...$params) + { + return $this->pow(...$params); + } } diff --git a/src/UnitConverter/Calculator/BinaryCalculator.php b/src/UnitConverter/Calculator/BinaryCalculator.php index 716fec20..0f397981 100644 --- a/src/UnitConverter/Calculator/BinaryCalculator.php +++ b/src/UnitConverter/Calculator/BinaryCalculator.php @@ -10,13 +10,15 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Calculator; /** - * Internal math helper class for floating point decimal - * percision + * A concrete calculator calss that uses the bcmath library + * to perform mathematical operations. + * + * @link http://php.net/manual/en/book.bc.php * * @version 1.0.0 * @since 0.4.1 @@ -24,40 +26,40 @@ */ class BinaryCalculator extends AbstractCalculator { - public function setPrecision(int $precision): CalculatorInterface - { - parent::setPrecision($precision); - bcscale($precision); - return $this; - } - - public function add ($leftOperand, $rightOperand) - { - return bcadd($leftOperand, $rightOperand); - } - - public function sub ($leftOperand, $rightOperand) - { - return bcsub($leftOperand, $rightOperand); - } - - public function mul ($leftOperand, $rightOperand) - { - return bcmul($leftOperand, $rightOperand); - } - - public function div ($dividend, $divisor) - { - return bcdiv($dividend, $divisor); - } - - public function mod ($dividend, $modulus) - { - return bcmod($dividend, $modulus); - } - - public function pow ($base, $exponent) - { - return bcpow($base, $exponent); - } + public function setPrecision(int $precision): CalculatorInterface + { + parent::setPrecision($precision); + bcscale($precision); + return $this; + } + + public function add ($leftOperand, $rightOperand) + { + return bcadd($leftOperand, $rightOperand); + } + + public function sub ($leftOperand, $rightOperand) + { + return bcsub($leftOperand, $rightOperand); + } + + public function mul ($leftOperand, $rightOperand) + { + return bcmul($leftOperand, $rightOperand); + } + + public function div ($dividend, $divisor) + { + return bcdiv($dividend, $divisor); + } + + public function mod ($dividend, $modulus) + { + return bcmod($dividend, $modulus); + } + + public function pow ($base, $exponent) + { + return bcpow($base, $exponent); + } } diff --git a/src/UnitConverter/Calculator/CalculatorInterface.php b/src/UnitConverter/Calculator/CalculatorInterface.php index f0bd0851..13d58893 100644 --- a/src/UnitConverter/Calculator/CalculatorInterface.php +++ b/src/UnitConverter/Calculator/CalculatorInterface.php @@ -10,13 +10,13 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Calculator; /** - * Internal math helper class for floating point decimal - * percision + * The calculator interface that all abstract & concrete calculator + * classes should implement. * * @version 1.0.0 * @since 0.4.1 @@ -24,72 +24,99 @@ */ interface CalculatorInterface { - /** - * Set default decimal precision for all math functions - * - * @param int $precision The amount of decimal places that will be returned - * @return Calculator - */ - public function setPrecision (int $precision): CalculatorInterface; + /** + * Set default decimal precision for all math functions + * + * @param int $precision The amount of decimal places that will be returned + * @return Calculator + */ + public function setPrecision (int $precision): CalculatorInterface; - /** - * Returns the current decimal precision for the calculator - * - * @return int - */ - public function getPrecision (): int; + /** + * Use one of the PHP_ROUND_HALF_* constants to specify + * the mode in which rounding occurs. + * + * @link https://secure.php.net/manual/en/function.round.php + * + * @param int $mode The mode in which rounding occurs + * @return CalculatorInterface + */ + public function setRoundingMode (int $roundingMode): CalculatorInterface; - /** - * Add two arbitrary precision numbers - * - * @param int|float|string $leftOperand The number left of the operator - * @param int|float|string $rightOperand The number right of the operator - * @return int|float|string - */ - public function add ($leftOperand, $rightOperand); + /** + * Returns the current decimal precision for the calculator + * + * @return int + */ + public function getPrecision (): int; - /** - * Subtract one arbitrary precision number from another - * - * @param int|float|string $leftOperand The number left of the operator - * @param int|float|string $rightOperand The number right of the operator - * @return int|float|string - */ - public function sub ($leftOperand, $rightOperand); + /** + * Return the current rounding mode + * + * @return int + */ + public function getRoundingMode (): int; - /** - * Multiply two arbitrary precision numbers - * - * @param int|float|string $leftOperand The number left of the operator - * @param int|float|string $rightOperand The number right of the operator - * @return int|float|string - */ - public function mul ($leftOperand, $rightOperand); + /** + * Add two arbitrary precision numbers + * + * @param int|float|string $leftOperand The number left of the operator + * @param int|float|string $rightOperand The number right of the operator + * @return int|float|string + */ + public function add ($leftOperand, $rightOperand); - /** - * Divide two arbitrary precision numbers - * - * @param int|float|string $dividend The number beind divided - * @param int|float|string $divisor The number that is doing the dividing - * @return int|float|string - */ - public function div ($dividend, $divisor); + /** + * Subtract one arbitrary precision number from another + * + * @param int|float|string $leftOperand The number left of the operator + * @param int|float|string $rightOperand The number right of the operator + * @return int|float|string + */ + public function sub ($leftOperand, $rightOperand); - /** - * Get modulus of an arbitrary precision number - * - * @param int|float|string $dividend The dividend as a string - * @param int|float|string $modulus The modulus as a string - * @return int|float|string - */ - public function mod ($dividend, $modulus); + /** + * Multiply two arbitrary precision numbers + * + * @param int|float|string $leftOperand The number left of the operator + * @param int|float|string $rightOperand The number right of the operator + * @return int|float|string + */ + public function mul ($leftOperand, $rightOperand); - /** - * Raise an arbitrary precision number to another - * - * @param int|float|string $base The base, as a string. - * @param int|float|string $exponent The exponent, as a string. If the exponent is non-integral, it is truncated. The valid range of the exponent is platform specific, but is at least -2147483648 to 2147483647. - * @return int|float|string - */ - public function pow ($base, $exponent); + /** + * Divide two arbitrary precision numbers + * + * @param int|float|string $dividend The number beind divided + * @param int|float|string $divisor The number that is doing the dividing + * @return int|float|string + */ + public function div ($dividend, $divisor); + + /** + * Get modulus of an arbitrary precision number + * + * @param int|float|string $dividend The dividend as a string + * @param int|float|string $modulus The modulus as a string + * @return int|float|string + */ + public function mod ($dividend, $modulus); + + /** + * Raise an arbitrary precision number to another + * + * @param int|float|string $base The base, as a string. + * @param int|float|string $exponent The exponent, as a string. If the exponent is non-integral, it is truncated. The valid range of the exponent is platform specific, but is at least -2147483648 to 2147483647. + * @return int|float|string + */ + public function pow ($base, $exponent); + + /** + * Rounds a float. + * + * @param int|float|string $value The value to round + * @param int $precision The number of decimal digits to round to. + * @return int|float|string + */ + public function round ($value, int $precision = null); } diff --git a/src/UnitConverter/Calculator/SimpleCalculator.php b/src/UnitConverter/Calculator/SimpleCalculator.php index 6b0c95ab..e5e48e90 100644 --- a/src/UnitConverter/Calculator/SimpleCalculator.php +++ b/src/UnitConverter/Calculator/SimpleCalculator.php @@ -10,13 +10,19 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Calculator; /** - * Internal math helper class for floating point decimal - * percision + * A basic implementation of the CalculatorInterface for performing + * mathematical operations with. + * + * @NOTE Due to the way that computers handle floating decimals, the + * results that this calculator yields may be less than accurate. To increase + * the accuracy of your results, you should round to more decimal places. + * + * @see UnitConverter\UnitConverter::convert() Increase rounding places on the fly. * * @version 1.0.0 * @since 0.4.1 @@ -24,84 +30,33 @@ */ class SimpleCalculator extends AbstractCalculator { - /** - * @var int $roundingMode The mode in which rounding occurs. Use one of the PHP_ROUND_HALF_* constants. - */ - protected $roundingMode; - - public function __construct (int $precision = 2, int $roundingMode = PHP_ROUND_HALF_UP) - { - parent::__construct($precision); - $this->setRoundingMode($roundingMode); - } - - /** - * Use one of the PHP_ROUND_HALF_* constants to specify - * the mode in which rounding occurs. - * - * @link https://secure.php.net/manual/en/function.round.php - * - * @param int $mode The mode in which rounding occurs - * @return CalculatorInterface - */ - public function setRoundingMode (int $roundingMode = PHP_ROUND_HALF_UP): CalculatorInterface - { - $this->roundingMode = $roundingMode; - return $this; - } - - /** - * Return the current rounding mode - * - * @return int - */ - public function getRoundingMode (): int - { - return $this->roundingMode; - } - - /** - * Return the result of a rounded float - * - * @param int|float $value The value to round - * @return float - */ - public function round ($value, int $percision = null): float - { - return round( - $value, - ($percision ?? $this->getPrecision()), - $this->getRoundingMode() - ); - } - - public function add ($leftOperand, $rightOperand) - { - return ($leftOperand + $rightOperand); - } - - public function sub ($leftOperand, $rightOperand) - { - return ($leftOperand - $rightOperand); - } - - public function mul ($leftOperand, $rightOperand) - { - return ($leftOperand * $rightOperand); - } - - public function div ($dividend, $divisor) - { - return ($dividend / $divisor); - } - - public function mod ($dividend, $modulus) - { - return ($dividend % $modulus); - } - - public function pow ($base, $exponent) - { - return pow($base, $exponent); - } + public function add ($leftOperand, $rightOperand) + { + return ($leftOperand + $rightOperand); + } + + public function sub ($leftOperand, $rightOperand) + { + return ($leftOperand - $rightOperand); + } + + public function mul ($leftOperand, $rightOperand) + { + return ($leftOperand * $rightOperand); + } + + public function div ($dividend, $divisor) + { + return ($dividend / $divisor); + } + + public function mod ($dividend, $modulus) + { + return ($dividend % $modulus); + } + + public function pow ($base, $exponent) + { + return pow($base, $exponent); + } } diff --git a/src/UnitConverter/Exception/MissingCalculatorException.php b/src/UnitConverter/Exception/MissingCalculatorException.php index 97d20ce8..f1001ad4 100644 --- a/src/UnitConverter/Exception/MissingCalculatorException.php +++ b/src/UnitConverter/Exception/MissingCalculatorException.php @@ -10,14 +10,18 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Exception; use OutOfBoundsException; /** - * Exception thrown when the unit converter is missing a calculator + * Exception to be thrown when a unit converter is missing a calculator. + * + * @version 1.0.0 + * @since 0.4.1 + * @author Jordan Brauer */ class MissingCalculatorException extends OutOfBoundsException { diff --git a/src/UnitConverter/Exception/MissingUnitRegistryException.php b/src/UnitConverter/Exception/MissingUnitRegistryException.php index 680d7f7c..af941ae3 100644 --- a/src/UnitConverter/Exception/MissingUnitRegistryException.php +++ b/src/UnitConverter/Exception/MissingUnitRegistryException.php @@ -10,14 +10,18 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Exception; use OutOfBoundsException; /** - * Exception thrown when the unit converter is missing a registry + * Exception to be thrown when a unit converter is missing a registry. + * + * @version 1.0.0 + * @since 0.3.9 + * @author Jordan Brauer */ class MissingUnitRegistryException extends OutOfBoundsException { diff --git a/src/UnitConverter/Exception/UnknownMeasurementTypeException.php b/src/UnitConverter/Exception/UnknownMeasurementTypeException.php index 6d52147a..79d88d69 100644 --- a/src/UnitConverter/Exception/UnknownMeasurementTypeException.php +++ b/src/UnitConverter/Exception/UnknownMeasurementTypeException.php @@ -10,14 +10,18 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Exception; use OutOfBoundsException; /** - * Exception thrown when a unit uses a non-existent type of measurement + * Exception to be thrown when a unit uses a non-existent type of measurement + * + * @version 1.0.0 + * @since 0.3.9 + * @author Jordan Brauer */ class UnknownMeasurementTypeException extends OutOfBoundsException { diff --git a/src/UnitConverter/Exception/UnknownUnitOfMeasureException.php b/src/UnitConverter/Exception/UnknownUnitOfMeasureException.php index 51cc0c23..72750a08 100644 --- a/src/UnitConverter/Exception/UnknownUnitOfMeasureException.php +++ b/src/UnitConverter/Exception/UnknownUnitOfMeasureException.php @@ -10,14 +10,18 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Exception; use OutOfBoundsException; /** - * Exception thrown when a conversion is attemped on an unknown unit + * Exception to be thrown when a conversion is attemped on an unknown unit + * + * @version 1.0.0 + * @since 0.3.9 + * @author Jordan Brauer */ class UnknownUnitOfMeasureException extends OutOfBoundsException { diff --git a/src/UnitConverter/Measure.php b/src/UnitConverter/Measure.php index 3a0f347e..3094764d 100644 --- a/src/UnitConverter/Measure.php +++ b/src/UnitConverter/Measure.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter; @@ -19,28 +19,28 @@ * default types of measurement. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Measure { - const LENGTH = "length"; + const LENGTH = "length"; - const AREA = "area"; + const AREA = "area"; - const VOLUME = "volume"; + const VOLUME = "volume"; - const MASS = "mass"; + const MASS = "mass"; - const SPEED = "speed"; + const SPEED = "speed"; - const PLANE_ANGLE = "plane_angle"; + const PLANE_ANGLE = "plane_angle"; - const TEMPERATURE = "temperature"; + const TEMPERATURE = "temperature"; - const PRESSURE = "pressure"; + const PRESSURE = "pressure"; - const TIME = "time"; + const TIME = "time"; - const ENERGY = "energy"; + const ENERGY = "energy"; } diff --git a/src/UnitConverter/Registry/UnitRegistry.php b/src/UnitConverter/Registry/UnitRegistry.php index 7a26ffec..2b170494 100644 --- a/src/UnitConverter/Registry/UnitRegistry.php +++ b/src/UnitConverter/Registry/UnitRegistry.php @@ -1,6 +1,6 @@ @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Registry; @@ -24,145 +24,144 @@ * to store and retrieve instances of the UnitInterface. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class UnitRegistry implements UnitRegistryInterface { - /** - * @var array $store A two-dimensional array containing available types of measuerment that each contain their available units of measure. - */ - protected $store = array(); - - /** - * Public constructor function for the unit registry. - * - * @param UnitInterface[] A one-dimensional array of UnitInterface objects to be registered upon construction. - * @return self - */ - public function __construct (array $units = array()) - { - $this->store = array( - Measure::LENGTH => array(), - Measure::AREA => array(), - Measure::VOLUME => array(), - Measure::MASS => array(), - Measure::SPEED => array(), - Measure::PLANE_ANGLE => array(), - Measure::TEMPERATURE => array(), - Measure::PRESSURE => array(), - Measure::TIME => array(), - Measure::ENERGY => array(), - ); - - if (count($units) > 0) - $this->registerUnits($units); - } - - public function isMeasurementRegistered (string $measurement) : bool - { - return array_key_exists($measurement, $this->store); - } - - public function isUnitRegistered (string $symbol) : bool - { - foreach ($this->store as $measurement => $units) { - if (array_key_exists($symbol, $units)) - return true; + /** + * @var array $store A two-dimensional array containing available types of measuerment that each contain their available units of measure. + */ + protected $store = array(); + + /** + * Public constructor function for the unit registry. + * + * @param UnitInterface[] $units A one-dimensional array of UnitInterface objects to be registered upon construction. + * @return self + */ + public function __construct (array $units = array()) + { + $this->store = array( + Measure::LENGTH => array(), + Measure::AREA => array(), + Measure::VOLUME => array(), + Measure::MASS => array(), + Measure::SPEED => array(), + Measure::PLANE_ANGLE => array(), + Measure::TEMPERATURE => array(), + Measure::PRESSURE => array(), + Measure::TIME => array(), + Measure::ENERGY => array(), + ); + + if (count($units) > 0) + $this->registerUnits($units); } - return false; - } + public function isMeasurementRegistered (string $measurement): bool + { + return array_key_exists($measurement, $this->store); + } - public function loadUnit (string $symbol) : ?UnitInterface - { - if ($this->isUnitRegistered($symbol) === false) - throw new UnknownUnitOfMeasureException("Trying to access unregistered unit of '{$symbol}'"); + public function isUnitRegistered (string $symbol): bool + { + foreach ($this->store as $measurement => $units) { + if (array_key_exists($symbol, $units)) + return true; + } - foreach ($this->store as $measurement => $units) { - if (array_key_exists($symbol, $units)) - return $this->store[$measurement][$symbol]; + return false; } - } - public function listMeasurements () : array - { - return array_keys($this->store); - } + public function loadUnit (string $symbol): ?UnitInterface + { + if ($this->isUnitRegistered($symbol) === false) + throw new UnknownUnitOfMeasureException("Trying to access unregistered unit of '{$symbol}'"); - public function listUnits (string $measurement = null) : array - { - if ($measurement) { - return array_keys($this->store[$measurement]); + foreach ($this->store as $measurement => $units) { + if (array_key_exists($symbol, $units)) + return $this->store[$measurement][$symbol]; + } } - $registeredUnits = array(); - - foreach ($this->store as $measurements) { - foreach ($measurements as $unit) { - array_push($registeredUnits, $unit->getSymbol()); - } + public function listMeasurements (): array + { + return array_keys($this->store); } - return $registeredUnits; - } + public function listUnits (string $measurement = null): array + { + if ($measurement) + return array_keys($this->store[$measurement]); - public function registerMeasurement (string $measurement) : void - { - if ($this->isMeasurementRegistered($measurement) === false) - $this->store[$measurement] = $measurement; - } + $registeredUnits = array(); - public function registerMeasurements (array $measurements) : void - { - foreach ($measurements as $measurement) { - $this->registerMeasurement($measurement); + foreach ($this->store as $measurements) { + foreach ($measurements as $unit) { + array_push($registeredUnits, $unit->getSymbol()); + } + } + + return $registeredUnits; } - } - public function registerUnit (UnitInterface $unit) : void - { - if (!$this->isMeasurementRegistered($unit->getUnitOf())) - throw new UnknownMeasurementTypeException("Trying to register unit '{$unit->getName()}' to an unregisted measurement of '{$unit->getUnitOf()}'"); + public function registerMeasurement (string $measurement): void + { + if ($this->isMeasurementRegistered($measurement) === false) + $this->store[$measurement] = $measurement; + } - $this->store[$unit->getUnitOf()][$unit->getSymbol()] = $unit; - } + public function registerMeasurements (array $measurements): void + { + foreach ($measurements as $measurement) { + $this->registerMeasurement($measurement); + } + } - public function registerUnits (array $units) : void - { - foreach ($units as $unit) { - $this->registerUnit($unit); + public function registerUnit (UnitInterface $unit): void + { + if (!$this->isMeasurementRegistered($unit->getUnitOf())) + throw new UnknownMeasurementTypeException("Trying to register unit '{$unit->getName()}' to an unregisted measurement of '{$unit->getUnitOf()}'"); + + $this->store[$unit->getUnitOf()][$unit->getSymbol()] = $unit; } - } - public function unregisterMeasurement (string $measurement) : void - { - if (!$this->isMeasurementRegistered($measurement)) - throw new UnknownMeasurementTypeException("Trying to unregister a nonexistent measurement type {$measurement}"); + public function registerUnits (array $units): void + { + foreach ($units as $unit) { + $this->registerUnit($unit); + } + } - unset($this->store[$measurement]); - } + public function unregisterMeasurement (string $measurement): void + { + if (!$this->isMeasurementRegistered($measurement)) + throw new UnknownMeasurementTypeException("Trying to unregister a nonexistent measurement type {$measurement}"); - public function unregisterMeasurements(array $measurements) : void - { - foreach ($measurements as $measurement) { - $this->unregisterMeasurement($measurement); + unset($this->store[$measurement]); } - } - public function unregisterUnit (string $symbol) : void - { - if ($this->isUnitRegistered($symbol) === false) - throw new UnknownUnitOfMeasureException("Trying to unregister a nonexistent unit {$symbol}"); + public function unregisterMeasurements(array $measurements): void + { + foreach ($measurements as $measurement) { + $this->unregisterMeasurement($measurement); + } + } - $unit = $this->loadUnit($symbol); - unset($this->store[$unit->getUnitOf()][$symbol]); - } + public function unregisterUnit (string $symbol): void + { + if ($this->isUnitRegistered($symbol) === false) + throw new UnknownUnitOfMeasureException("Trying to unregister a nonexistent unit {$symbol}"); + + $unit = $this->loadUnit($symbol); + unset($this->store[$unit->getUnitOf()][$symbol]); + } - public function unregisterUnits (array $symbols) : void - { - foreach ($symbols as $unit) { - $this->unregisterUnit($unit); + public function unregisterUnits (array $symbols): void + { + foreach ($symbols as $unit) { + $this->unregisterUnit($unit); + } } - } } diff --git a/src/UnitConverter/Registry/UnitRegistryInterface.php b/src/UnitConverter/Registry/UnitRegistryInterface.php index 7b7728c5..18be2c0c 100644 --- a/src/UnitConverter/Registry/UnitRegistryInterface.php +++ b/src/UnitConverter/Registry/UnitRegistryInterface.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Registry; @@ -21,125 +21,125 @@ * and types of measurement. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ interface UnitRegistryInterface { - /** - * Determine if a measurement type is registered to the unit registry or not. - * - * @param string $measurement The name of the measurment being checked, e.g. "length". - */ - public function isMeasurementRegistered (string $measurement) : bool; - - /** - * Determine if a specific unit of measure is registered to the unit registry or not. - * - * @param string $symbol The symbol notation of the unit being checked, e.g., "cm". - */ - public function isUnitRegistered (string $symbol) : bool; - - /** - * Fetch a unit from the unit registry for use elsewhere. - * - * @throws UnknownUnitOfMeasureException An out of bounds exception will be thrown if loading an unregistered unit is attempted. - * @param string $symbol The symbol notation of the unit being loaded. - * @return null|UnitInterface - */ - public function loadUnit (string $symbol) : ?UnitInterface; - - /** - * Return a one-dimensional array of currently supported measurement types. - * - * @return array - */ - public function listMeasurements () : array; - - /** - * Return a one-dimensional array of currently supported units. Optionally - * pass a string equal to a type of measurement (e.g. "length") to return - * only units of the specifed type. - * - * @param string $measurement - */ - public function listUnits (string $measurement = null) : array; - - /** - * Register a single measurement to the unit registry by passing a - * string as the argument - * - * @NOTE In order to prevent unwanted overwritting of measurement - * types (especially those with many registered units) - you must - * unregister the measurement first with ::unregisterMeasurement(). - * - * @param string $measurement - * @return void - */ - public function registerMeasurement (string $measurement) : void; - - /** - * Register many measurements to the unit registry by passing an - * array of measurement strings as the argument - * - * @param array $measurements - * @return void - */ - public function registerMeasurements (array $measurements) : void; - - /** - * Register a single unit to the unit registry by passing an - * instance of a UnitInterface as it's argument - * - * @param UnitInterface $unit - * @throws UnknownMeasurementTypeException This will be thrown when an attempted unit registration is made on an unexisting measurement. - * @return void - */ - public function registerUnit (UnitInterface $unit) : void; - - /** - * Register many units to the unit registry by passing an array of unit - * classes as it's argument. - * - * @param UnitInterface[] $units - * @return void - */ - public function registerUnits (array $units) : void; - - /** - * Unegister a single measurement from the unit registry. - * - * @NOTE: Invoking this method will also unregister all - * units belonging to the measurement that is being unregistered. - * - * @param string $symbol - * @throws UnknownMeasurementTypeException An error exception will be thrown if you attempt to unregister a non-existing measurement type. - * @return void - */ - public function unregisterMeasurement (string $symbol) : void; - - /** - * Unegister many units from the unit registry - * - * @param string[] $symbols - * @return void - */ - public function unregisterMeasurements (array $symbols) : void; - - /** - * Unegister a single unit from the unit registry - * - * @param string $symbol - * @throws UnknownUnitOfMeasureException An error exception will be thrown if you attempt to unregister a non-existing unit of measure. - * @return void - */ - public function unregisterUnit (string $symbol) : void; - - /** - * Unegister many units from the unit registry - * - * @param string[] $symbols - * @return void - */ - public function unregisterUnits (array $symbols) : void; + /** + * Determine if a measurement type is registered to the unit registry or not. + * + * @param string $measurement The name of the measurment being checked, e.g. "length". + */ + public function isMeasurementRegistered (string $measurement): bool; + + /** + * Determine if a specific unit of measure is registered to the unit registry or not. + * + * @param string $symbol The symbol notation of the unit being checked, e.g., "cm". + */ + public function isUnitRegistered (string $symbol): bool; + + /** + * Fetch a unit from the unit registry for use elsewhere. + * + * @throws UnknownUnitOfMeasureException An out of bounds exception will be thrown if loading an unregistered unit is attempted. + * @param string $symbol The symbol notation of the unit being loaded. + * @return null|UnitInterface + */ + public function loadUnit (string $symbol): ?UnitInterface; + + /** + * Return a one-dimensional array of currently supported measurement types. + * + * @return array + */ + public function listMeasurements (): array; + + /** + * Return a one-dimensional array of currently supported units. Optionally + * pass a string equal to a type of measurement (e.g. "length") to return + * only units of the specifed type. + * + * @param string $measurement + */ + public function listUnits (string $measurement = null): array; + + /** + * Register a single measurement to the unit registry by passing a + * string as the argument + * + * @NOTE In order to prevent unwanted overwritting of measurement + * types (especially those with many registered units) - you must + * unregister the measurement first with ::unregisterMeasurement(). + * + * @param string $measurement + * @return void + */ + public function registerMeasurement (string $measurement): void; + + /** + * Register many measurements to the unit registry by passing an + * array of measurement strings as the argument + * + * @param array $measurements + * @return void + */ + public function registerMeasurements (array $measurements): void; + + /** + * Register a single unit to the unit registry by passing an + * instance of a UnitInterface as it's argument + * + * @param UnitInterface $unit + * @throws UnknownMeasurementTypeException Thrown when an attempted unit registration is made on an unexisting measurement. + * @return void + */ + public function registerUnit (UnitInterface $unit): void; + + /** + * Register many units to the unit registry by passing an array of unit + * classes as it's argument. + * + * @param UnitInterface[] $units + * @return void + */ + public function registerUnits (array $units): void; + + /** + * Unegister a single measurement from the unit registry. + * + * @NOTE: Invoking this method will also unregister all + * units belonging to the measurement that is being unregistered. + * + * @param string $symbol + * @throws UnknownMeasurementTypeException An error exception will be thrown if you attempt to unregister a non-existing measurement type. + * @return void + */ + public function unregisterMeasurement (string $symbol): void; + + /** + * Unegister many units from the unit registry + * + * @param string[] $symbols + * @return void + */ + public function unregisterMeasurements (array $symbols): void; + + /** + * Unegister a single unit from the unit registry + * + * @param string $symbol + * @throws UnknownUnitOfMeasureException An error exception will be thrown if you attempt to unregister a non-existing unit of measure. + * @return void + */ + public function unregisterUnit (string $symbol): void; + + /** + * Unegister many units from the unit registry + * + * @param string[] $symbols + * @return void + */ + public function unregisterUnits (array $symbols): void; } diff --git a/src/UnitConverter/Unit/AbstractUnit.php b/src/UnitConverter/Unit/AbstractUnit.php index 2eb4a8a6..518f3530 100644 --- a/src/UnitConverter/Unit/AbstractUnit.php +++ b/src/UnitConverter/Unit/AbstractUnit.php @@ -10,163 +10,159 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit; use UnitConverter\Calculator\CalculatorInterface; /** - * This class is the base class for all unit of measurement classes. When creating - * a new/custom unit of measure, extend from this class. The Bare minimum - * requirements for usage are defining all properties. + * This class is the base class for all unit of measurement classes. + * When creating a new/custom unit of measure, extend from this class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ abstract class AbstractUnit implements UnitInterface { - /** - * @var string $name The units' full name. - */ - protected $name; - - /** - * @var string $symbol The units' symbol notation (e.g., meter = m). - */ - protected $symbol; - - /** - * @var string The scientific symbol of the unit - */ - protected $scientificSymbol; - - /** - * @var string $unitOf What is this unit measuring? Length, temperatutre, etc. - */ - protected $unitOf; - - /** - * @var UnitInterface $base The units' base unit. - */ - protected $base; - - /** - * @var float $units The amount of base units needed to make up 1 unit. - */ - protected $units; - - public function __construct () - { - $this->configure(); - } - - /** - * Configure the current unit of measure. - * - * @return void - */ - protected function configure () : void - { - } - - /** - * Calculate the amount of required base units to make up 1 unit. - * - * @param CalculatorInterface $calculator - * @param int|float|string $value - * @param UnitInterface $to - * @param int $percision The decimal percision to be calculated - * @return null|int|float|string - */ - protected function calculate (CalculatorInterface $calculator, $value, UnitInterface $to, int $percision = null) - { - return null; - } - - /** - * Exposes access to the ::calculate() method. - * - * @param CalculatorInterface $calculator - * @param int|float|string $value - * @param UnitInterface $to - * @param int $percision The decimal percision to be calculated - * @return null|int|float|string - */ - public function convert (CalculatorInterface $calculator, $value, UnitInterface $to, int $percision = null) - { - return $this->calculate($calculator, $value, $to, $percision); - } - - public function setName (string $name) : UnitInterface - { - $this->name = $name; - return $this; - } - - public function getName () : string - { - return $this->name; - } - - public function setSymbol (string $symbol) : UnitInterface - { - $this->symbol = $symbol; - return $this; - } - - public function getSymbol () : string - { - return $this->symbol; - } - - public function setUnitOf (string $unitOf) : UnitInterface - { - $this->unitOf = $unitOf; - return $this; - } - - public function getUnitOf () : string - { - return $this->unitOf; - } - - public function setBase ($base) : UnitInterface - { - $this->base = $base; - return $this; - } - - public function getBase () : UnitInterface - { - return new $this->base; - } - - public function setUnits (float $units) : UnitInterface - { - $this->units = $units; - return $this; - } - - public function getUnits () : float - { - return $this->units; - } - - public function getBaseUnits () : float - { - return $this->getBase()->getUnits(); - } - - public function getScientificSymbol () : string - { - return $this->scientificSymbol; - } - - public function setScientificSymbol (string $scientificSymbol) : UnitInterface - { - $this->scientificSymbol = $scientificSymbol; - return $this; - } + /** + * @var string $name The units' full name. + */ + protected $name; + + /** + * @var string $symbol The units' symbol notation (e.g., meter = m). + */ + protected $symbol; + + /** + * @var string The scientific symbol of the unit + */ + protected $scientificSymbol; + + /** + * @var string $unitOf What is this unit measuring? Length, temperatutre, etc. + */ + protected $unitOf; + + /** + * @var string[UnitInterface] $base The units' base unit. + */ + protected $base; + + /** + * @var float $units The amount of base units needed to make up 1 unit. + */ + protected $units; + + /** + * Public constructor function for units of measurement. + */ + public function __construct () + { + $this->configure(); + } + + /** + * Configure the current unit of measure. + * + * @return void + */ + protected function configure (): void + { + } + + /** + * Calculate the amount of required base units to make up 1 unit. + * + * @param CalculatorInterface $calculator + * @param int|float|string $value + * @param UnitInterface $to + * @param int $precision The decimal percision to be calculated + * @return null|int|float|string + */ + protected function calculate (CalculatorInterface $calculator, $value, UnitInterface $to, int $precision = null) + { + return null; + } + + /** + * Exposes access to the ::calculate() method. + */ + public function convert (...$params) + { + return $this->calculate(...$params); + } + + public function setName (string $name): UnitInterface + { + $this->name = $name; + return $this; + } + + public function getName (): string + { + return $this->name; + } + + public function setSymbol (string $symbol): UnitInterface + { + $this->symbol = $symbol; + return $this; + } + + public function getSymbol (): string + { + return $this->symbol; + } + + public function getScientificSymbol (): string + { + return $this->scientificSymbol; + } + + public function setScientificSymbol (string $scientificSymbol): UnitInterface + { + $this->scientificSymbol = $scientificSymbol; + return $this; + } + + public function setUnitOf (string $unitOf): UnitInterface + { + $this->unitOf = $unitOf; + return $this; + } + + public function getUnitOf (): string + { + return $this->unitOf; + } + + public function setBase ($base): UnitInterface + { + $this->base = $base; + return $this; + } + + public function getBase (): UnitInterface + { + return new $this->base; + } + + public function setUnits (float $units): UnitInterface + { + $this->units = $units; + return $this; + } + + public function getUnits (): float + { + return $this->units; + } + + public function getBaseUnits (): float + { + return $this->getBase()->getUnits(); + } } diff --git a/src/UnitConverter/Unit/Area/Acre.php b/src/UnitConverter/Unit/Area/Acre.php index 4c54bd10..0755aff8 100644 --- a/src/UnitConverter/Unit/Area/Acre.php +++ b/src/UnitConverter/Unit/Area/Acre.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Area; @@ -18,19 +18,19 @@ * Acre data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer - */ +*/ class Acre extends AreaUnit { - protected function configure () : void - { - $this - ->setName("acre") + protected function configure (): void + { + $this + ->setName("acre") - ->setSymbol("ac") + ->setSymbol("ac") - ->setUnits(4046.86) - ; - } + ->setUnits(4046.86) + ; + } } diff --git a/src/UnitConverter/Unit/Area/AreaUnit.php b/src/UnitConverter/Unit/Area/AreaUnit.php index 49c85924..65602afa 100644 --- a/src/UnitConverter/Unit/Area/AreaUnit.php +++ b/src/UnitConverter/Unit/Area/AreaUnit.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Area; @@ -23,12 +23,12 @@ * overriding the $unitOf and $base properties only if necessary. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ abstract class AreaUnit extends AbstractUnit { - protected $unitOf = Measure::AREA; + protected $unitOf = Measure::AREA; - protected $base = SquareMeter::class; + protected $base = SquareMeter::class; } diff --git a/src/UnitConverter/Unit/Area/Hectare.php b/src/UnitConverter/Unit/Area/Hectare.php index 6c2704f5..b9e264a1 100644 --- a/src/UnitConverter/Unit/Area/Hectare.php +++ b/src/UnitConverter/Unit/Area/Hectare.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Area; @@ -18,19 +18,19 @@ * Hectare data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Hectare extends AreaUnit { - protected function configure () : void - { - $this - ->setName("hectare") + protected function configure (): void + { + $this + ->setName("hectare") - ->setSymbol("ha") + ->setSymbol("ha") - ->setUnits(10000) - ; - } + ->setUnits(10000) + ; + } } diff --git a/src/UnitConverter/Unit/Area/SquareCentimeter.php b/src/UnitConverter/Unit/Area/SquareCentimeter.php index 6f54551e..e68e3eb0 100644 --- a/src/UnitConverter/Unit/Area/SquareCentimeter.php +++ b/src/UnitConverter/Unit/Area/SquareCentimeter.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Area; @@ -18,19 +18,19 @@ * Square centimeter data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class SquareCentimeter extends AreaUnit { - protected function configure () : void - { - $this - ->setName("square centimeter") + protected function configure (): void + { + $this + ->setName("square centimeter") - ->setSymbol("cm2") + ->setSymbol("cm2") - ->setUnits(0.0001) - ; - } + ->setUnits(0.0001) + ; + } } diff --git a/src/UnitConverter/Unit/Area/SquareFoot.php b/src/UnitConverter/Unit/Area/SquareFoot.php index 3ba43ded..f1455366 100644 --- a/src/UnitConverter/Unit/Area/SquareFoot.php +++ b/src/UnitConverter/Unit/Area/SquareFoot.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Area; @@ -18,19 +18,19 @@ * Square foot data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class SquareFoot extends AreaUnit { - protected function configure () : void - { - $this - ->setName("square foot") + protected function configure (): void + { + $this + ->setName("square foot") - ->setSymbol("ft2") + ->setSymbol("ft2") - ->setUnits(0.092903) - ; - } + ->setUnits(0.092903) + ; + } } diff --git a/src/UnitConverter/Unit/Area/SquareKilometer.php b/src/UnitConverter/Unit/Area/SquareKilometer.php index 02525974..4fce7dc4 100644 --- a/src/UnitConverter/Unit/Area/SquareKilometer.php +++ b/src/UnitConverter/Unit/Area/SquareKilometer.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Area; @@ -18,19 +18,19 @@ * Square kilometer data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class SquareKilometer extends AreaUnit { - protected function configure () : void - { - $this - ->setName("square kilometer") + protected function configure (): void + { + $this + ->setName("square kilometer") - ->setSymbol("km2") + ->setSymbol("km2") - ->setUnits(1000000) - ; - } + ->setUnits(1000000) + ; + } } diff --git a/src/UnitConverter/Unit/Area/SquareMeter.php b/src/UnitConverter/Unit/Area/SquareMeter.php index 0cf3cb8e..f8b5f88b 100644 --- a/src/UnitConverter/Unit/Area/SquareMeter.php +++ b/src/UnitConverter/Unit/Area/SquareMeter.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Area; @@ -19,19 +19,19 @@ * class as the $base property. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class SquareMeter extends AreaUnit { - protected function configure () : void - { - $this - ->setName("square meter") + protected function configure (): void + { + $this + ->setName("square meter") - ->setSymbol("m2") + ->setSymbol("m2") - ->setUnits(1) - ; - } + ->setUnits(1) + ; + } } diff --git a/src/UnitConverter/Unit/Area/SquareMile.php b/src/UnitConverter/Unit/Area/SquareMile.php index d6ba74c7..a31438cc 100644 --- a/src/UnitConverter/Unit/Area/SquareMile.php +++ b/src/UnitConverter/Unit/Area/SquareMile.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Area; @@ -18,19 +18,19 @@ * Square mile data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer - */ +*/ class SquareMile extends AreaUnit { - protected function configure () : void - { - $this - ->setName("square mile") + protected function configure (): void + { + $this + ->setName("square mile") - ->setSymbol("mi2") + ->setSymbol("mi2") - ->setUnits(2589988.11) - ; - } + ->setUnits(2589988.11) + ; + } } diff --git a/src/UnitConverter/Unit/Area/SquareMillimeter.php b/src/UnitConverter/Unit/Area/SquareMillimeter.php index 4e4a7ba4..83686c88 100644 --- a/src/UnitConverter/Unit/Area/SquareMillimeter.php +++ b/src/UnitConverter/Unit/Area/SquareMillimeter.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Area; @@ -18,19 +18,19 @@ * Square millimeter data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class SquareMillimeter extends AreaUnit { - protected function configure () : void - { - $this - ->setName("square millimeter") + protected function configure (): void + { + $this + ->setName("square millimeter") - ->setSymbol("mm2") + ->setSymbol("mm2") - ->setUnits(0.000001) - ; - } + ->setUnits(0.000001) + ; + } } diff --git a/src/UnitConverter/Unit/Energy/Calorie.php b/src/UnitConverter/Unit/Energy/Calorie.php index a5847681..37bedede 100644 --- a/src/UnitConverter/Unit/Energy/Calorie.php +++ b/src/UnitConverter/Unit/Energy/Calorie.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Energy; @@ -18,19 +18,19 @@ * Calorie unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Calorie extends EnergyUnit { - protected function configure () : void - { - $this - ->setName("calorie") + protected function configure (): void + { + $this + ->setName("calorie") - ->setSymbol("cal") + ->setSymbol("cal") - ->setUnits(4184) - ; - } + ->setUnits(4184) + ; + } } diff --git a/src/UnitConverter/Unit/Energy/EnergyUnit.php b/src/UnitConverter/Unit/Energy/EnergyUnit.php index 807ea34b..692cd7a6 100644 --- a/src/UnitConverter/Unit/Energy/EnergyUnit.php +++ b/src/UnitConverter/Unit/Energy/EnergyUnit.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Energy; @@ -23,12 +23,12 @@ * overriding the $unitOf and $base properties only if necessary. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ abstract class EnergyUnit extends AbstractUnit { - protected $unitOf = Measure::ENERGY; + protected $unitOf = Measure::ENERGY; - protected $base = Joule::class; + protected $base = Joule::class; } diff --git a/src/UnitConverter/Unit/Energy/FootPound.php b/src/UnitConverter/Unit/Energy/FootPound.php index 0d6a9518..3902ebdf 100644 --- a/src/UnitConverter/Unit/Energy/FootPound.php +++ b/src/UnitConverter/Unit/Energy/FootPound.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Energy; @@ -18,19 +18,19 @@ * FootPound unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class FootPound extends EnergyUnit { - protected function configure () : void - { - $this - ->setName("foot pound") + protected function configure (): void + { + $this + ->setName("foot pound") - ->setSymbol("ftlb") + ->setSymbol("ftlb") - ->setUnits(1.35582) - ; - } + ->setUnits(1.35582) + ; + } } diff --git a/src/UnitConverter/Unit/Energy/Joule.php b/src/UnitConverter/Unit/Energy/Joule.php index d5701f81..7fb0ea4a 100644 --- a/src/UnitConverter/Unit/Energy/Joule.php +++ b/src/UnitConverter/Unit/Energy/Joule.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Energy; @@ -18,19 +18,19 @@ * Joule unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Joule extends EnergyUnit { - protected function configure () : void - { - $this - ->setName("joule") + protected function configure (): void + { + $this + ->setName("joule") - ->setSymbol("J") + ->setSymbol("J") - ->setUnits(1) - ; - } + ->setUnits(1) + ; + } } diff --git a/src/UnitConverter/Unit/Energy/Kilojoule.php b/src/UnitConverter/Unit/Energy/Kilojoule.php index 91619fe8..b8fdc13b 100644 --- a/src/UnitConverter/Unit/Energy/Kilojoule.php +++ b/src/UnitConverter/Unit/Energy/Kilojoule.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Energy; @@ -18,19 +18,19 @@ * Kilojoule unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.3.9 * @author Andrew Boerema <1569403+andrewboerema@users.noreply.github.com> */ class Kilojoule extends EnergyUnit { - protected function configure () : void - { - $this - ->setName("kilojoule") + protected function configure (): void + { + $this + ->setName("kilojoule") - ->setSymbol("kJ") + ->setSymbol("kJ") - ->setUnits(1000) - ; - } + ->setUnits(1000) + ; + } } diff --git a/src/UnitConverter/Unit/Energy/KilowattHour.php b/src/UnitConverter/Unit/Energy/KilowattHour.php index bd89205e..7ece86a8 100644 --- a/src/UnitConverter/Unit/Energy/KilowattHour.php +++ b/src/UnitConverter/Unit/Energy/KilowattHour.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Energy; @@ -18,19 +18,19 @@ * KilowattHour unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.3.9 * @author Andrew Boerema <1569403+andrewboerema@users.noreply.github.com> */ class KilowattHour extends EnergyUnit { - protected function configure () : void - { - $this - ->setName("kilowatt hour") + protected function configure (): void + { + $this + ->setName("kilowatt hour") - ->setSymbol("kWh") + ->setSymbol("kWh") - ->setUnits(3600005.4468) - ; - } + ->setUnits(3600005.4468) + ; + } } diff --git a/src/UnitConverter/Unit/Energy/Megaelectronvolt.php b/src/UnitConverter/Unit/Energy/Megaelectronvolt.php index e827ee89..796b85ce 100644 --- a/src/UnitConverter/Unit/Energy/Megaelectronvolt.php +++ b/src/UnitConverter/Unit/Energy/Megaelectronvolt.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Energy; @@ -18,19 +18,19 @@ * Megaelectronvolt unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.3.9 * @author Andrew Boerema <1569403+andrewboerema@users.noreply.github.com> */ class Megaelectronvolt extends EnergyUnit { - protected function configure () : void - { - $this - ->setName("megaelectronvolt") + protected function configure (): void + { + $this + ->setName("megaelectronvolt") - ->setSymbol("MeV") + ->setSymbol("MeV") - ->setUnits(1.60218e-13) - ; - } + ->setUnits(1.60218e-13) + ; + } } diff --git a/src/UnitConverter/Unit/Energy/Megajoule.php b/src/UnitConverter/Unit/Energy/Megajoule.php index 6349788c..eb726b35 100644 --- a/src/UnitConverter/Unit/Energy/Megajoule.php +++ b/src/UnitConverter/Unit/Energy/Megajoule.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Energy; @@ -18,19 +18,19 @@ * Megajoule unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.3.9 * @author Andrew Boerema <1569403+andrewboerema@users.noreply.github.com> */ class Megajoule extends EnergyUnit { - protected function configure () : void - { - $this - ->setName("megajoule") + protected function configure (): void + { + $this + ->setName("megajoule") - ->setSymbol("MJ") + ->setSymbol("MJ") - ->setUnits(1000000) - ; - } + ->setUnits(1000000) + ; + } } diff --git a/src/UnitConverter/Unit/Energy/MegawattHour.php b/src/UnitConverter/Unit/Energy/MegawattHour.php index b102b127..210cbb72 100644 --- a/src/UnitConverter/Unit/Energy/MegawattHour.php +++ b/src/UnitConverter/Unit/Energy/MegawattHour.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Energy; @@ -18,19 +18,19 @@ * MegawattHour unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.3.9 * @author Andrew Boerema <1569403+andrewboerema@users.noreply.github.com> */ class MegawattHour extends EnergyUnit { - protected function configure () : void - { - $this - ->setName("megawatt hour") + protected function configure (): void + { + $this + ->setName("megawatt hour") - ->setSymbol("MWh") + ->setSymbol("MWh") - ->setUnits(3600005446.8) - ; - } + ->setUnits(3600005446.8) + ; + } } diff --git a/src/UnitConverter/Unit/Energy/NewtonMeter.php b/src/UnitConverter/Unit/Energy/NewtonMeter.php index c37c7e12..804c900e 100644 --- a/src/UnitConverter/Unit/Energy/NewtonMeter.php +++ b/src/UnitConverter/Unit/Energy/NewtonMeter.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Energy; @@ -18,19 +18,19 @@ * NewtonMeter unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.3.9 * @author Andrew Boerema <1569403+andrewboerema@users.noreply.github.com> */ class NewtonMeter extends EnergyUnit { - protected function configure () : void - { - $this - ->setName("newton meter") + protected function configure (): void + { + $this + ->setName("newton meter") - ->setSymbol("Nm") + ->setSymbol("Nm") - ->setUnits(1) - ; - } + ->setUnits(1) + ; + } } diff --git a/src/UnitConverter/Unit/Energy/WattHour.php b/src/UnitConverter/Unit/Energy/WattHour.php index 7bc074f7..1567c0f0 100644 --- a/src/UnitConverter/Unit/Energy/WattHour.php +++ b/src/UnitConverter/Unit/Energy/WattHour.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Energy; @@ -18,19 +18,19 @@ * WattHour unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class WattHour extends EnergyUnit { - protected function configure () : void - { - $this - ->setName("watt hour") + protected function configure (): void + { + $this + ->setName("watt hour") - ->setSymbol("Wh") + ->setSymbol("Wh") - ->setUnits(3600.0054468) - ; - } + ->setUnits(3600.0054468) + ; + } } diff --git a/src/UnitConverter/Unit/Length/AstronomicalUnit.php b/src/UnitConverter/Unit/Length/AstronomicalUnit.php index a83ccf2b..b4cd6538 100644 --- a/src/UnitConverter/Unit/Length/AstronomicalUnit.php +++ b/src/UnitConverter/Unit/Length/AstronomicalUnit.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Length; @@ -18,19 +18,19 @@ * AstronomicalUnit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class AstronomicalUnit extends LengthUnit { - protected function configure () : void - { - $this - ->setName("astronomical unit") + protected function configure (): void + { + $this + ->setName("astronomical unit") - ->setSymbol("au") + ->setSymbol("au") - ->setUnits(149597870700) - ; - } + ->setUnits(149597870700) + ; + } } diff --git a/src/UnitConverter/Unit/Length/Centimeter.php b/src/UnitConverter/Unit/Length/Centimeter.php index a2c466a2..5766f23d 100644 --- a/src/UnitConverter/Unit/Length/Centimeter.php +++ b/src/UnitConverter/Unit/Length/Centimeter.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Length; @@ -18,19 +18,19 @@ * Centimeter data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Centimeter extends LengthUnit { - protected function configure () : void - { - $this - ->setName("centimeter") + protected function configure (): void + { + $this + ->setName("centimeter") - ->setSymbol("cm") + ->setSymbol("cm") - ->setUnits(0.01) - ; - } + ->setUnits(0.01) + ; + } } diff --git a/src/UnitConverter/Unit/Length/Decimeter.php b/src/UnitConverter/Unit/Length/Decimeter.php index e50585d9..58e241ed 100644 --- a/src/UnitConverter/Unit/Length/Decimeter.php +++ b/src/UnitConverter/Unit/Length/Decimeter.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Length; @@ -18,19 +18,19 @@ * Decimeter data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Decimeter extends LengthUnit { - protected function configure () : void - { - $this - ->setName("decimeter") + protected function configure (): void + { + $this + ->setName("decimeter") - ->setSymbol("dm") + ->setSymbol("dm") - ->setUnits(0.1) - ; - } + ->setUnits(0.1) + ; + } } diff --git a/src/UnitConverter/Unit/Length/Foot.php b/src/UnitConverter/Unit/Length/Foot.php index e994cadb..7dfa0642 100644 --- a/src/UnitConverter/Unit/Length/Foot.php +++ b/src/UnitConverter/Unit/Length/Foot.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Length; @@ -18,19 +18,19 @@ * Foot data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Foot extends LengthUnit { - protected function configure () : void - { - $this - ->setName("foot") + protected function configure (): void + { + $this + ->setName("foot") - ->setSymbol("ft") + ->setSymbol("ft") - ->setUnits(0.3048) - ; - } + ->setUnits(0.3048) + ; + } } diff --git a/src/UnitConverter/Unit/Length/Hand.php b/src/UnitConverter/Unit/Length/Hand.php index a4078d09..a48d08f1 100644 --- a/src/UnitConverter/Unit/Length/Hand.php +++ b/src/UnitConverter/Unit/Length/Hand.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Length; @@ -18,19 +18,19 @@ * Hand data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Hand extends LengthUnit { - protected function configure () : void - { - $this - ->setName("hand") + protected function configure (): void + { + $this + ->setName("hand") - ->setSymbol("h") + ->setSymbol("h") - ->setUnits(0.1016) - ; - } + ->setUnits(0.1016) + ; + } } diff --git a/src/UnitConverter/Unit/Length/Inch.php b/src/UnitConverter/Unit/Length/Inch.php index a44d7ec8..a623db47 100644 --- a/src/UnitConverter/Unit/Length/Inch.php +++ b/src/UnitConverter/Unit/Length/Inch.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Length; @@ -18,19 +18,19 @@ * Inch data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Inch extends LengthUnit { - protected function configure () : void - { - $this - ->setName("inch") + protected function configure (): void + { + $this + ->setName("inch") - ->setSymbol("in") + ->setSymbol("in") - ->setUnits(0.0254) - ; - } + ->setUnits(0.0254) + ; + } } diff --git a/src/UnitConverter/Unit/Length/Kilometer.php b/src/UnitConverter/Unit/Length/Kilometer.php index 0b6a76d1..fb9ab9de 100644 --- a/src/UnitConverter/Unit/Length/Kilometer.php +++ b/src/UnitConverter/Unit/Length/Kilometer.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Length; @@ -18,19 +18,19 @@ * Kilometer data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Kilometer extends LengthUnit { - protected function configure () : void - { - $this - ->setName("kilometer") + protected function configure (): void + { + $this + ->setName("kilometer") - ->setSymbol("km") + ->setSymbol("km") - ->setUnits(1000) - ; - } + ->setUnits(1000) + ; + } } diff --git a/src/UnitConverter/Unit/Length/LengthUnit.php b/src/UnitConverter/Unit/Length/LengthUnit.php index bde7e64d..ced6ac89 100644 --- a/src/UnitConverter/Unit/Length/LengthUnit.php +++ b/src/UnitConverter/Unit/Length/LengthUnit.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Length; @@ -23,12 +23,12 @@ * overriding the $unitOf and $base properties only if necessary. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ abstract class LengthUnit extends AbstractUnit { - protected $unitOf = Measure::LENGTH; + protected $unitOf = Measure::LENGTH; - protected $base = Meter::class; + protected $base = Meter::class; } diff --git a/src/UnitConverter/Unit/Length/Lightyear.php b/src/UnitConverter/Unit/Length/Lightyear.php index 09af8e6b..49f6da45 100644 --- a/src/UnitConverter/Unit/Length/Lightyear.php +++ b/src/UnitConverter/Unit/Length/Lightyear.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Length; @@ -18,21 +18,21 @@ * Lightyear data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Lightyear extends LengthUnit { - protected function configure () : void - { - $this - ->setName("lightyear") + protected function configure (): void + { + $this + ->setName("lightyear") - ->setSymbol("ly") + ->setSymbol("ly") - # Metric (SI) Units = 9.4607 × 1015 m - # – OR – 9.4607 Pm - ->setUnits(9460730472580800) - ; - } + # Metric (SI) Units = 9.4607 × 1015 m + # – OR – 9.4607 Pm + ->setUnits(9460730472580800) + ; + } } diff --git a/src/UnitConverter/Unit/Length/Meter.php b/src/UnitConverter/Unit/Length/Meter.php index d5dbf96f..e8af3fe7 100644 --- a/src/UnitConverter/Unit/Length/Meter.php +++ b/src/UnitConverter/Unit/Length/Meter.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Length; @@ -18,19 +18,19 @@ * Meter data class. All units of Length are based off of Meter. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Meter extends LengthUnit { - protected function configure () : void - { - $this - ->setName("meter") + protected function configure (): void + { + $this + ->setName("meter") - ->setSymbol("m") + ->setSymbol("m") - ->setUnits(1) - ; - } + ->setUnits(1) + ; + } } diff --git a/src/UnitConverter/Unit/Length/Micrometer.php b/src/UnitConverter/Unit/Length/Micrometer.php index 6b4ed613..af31414a 100644 --- a/src/UnitConverter/Unit/Length/Micrometer.php +++ b/src/UnitConverter/Unit/Length/Micrometer.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Length; @@ -18,20 +18,20 @@ * Micrometer data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Micrometer extends LengthUnit { - protected function configure () : void - { - $this - ->setName("micrometer") + protected function configure (): void + { + $this + ->setName("micrometer") - ->setSymbol("µm") + ->setSymbol("µm") - # 1.0E-6 - ->setUnits(0.000001) - ; - } + # 1.0E-6 + ->setUnits(0.000001) + ; + } } diff --git a/src/UnitConverter/Unit/Length/Mile.php b/src/UnitConverter/Unit/Length/Mile.php index dca2819e..5c5719f4 100644 --- a/src/UnitConverter/Unit/Length/Mile.php +++ b/src/UnitConverter/Unit/Length/Mile.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Length; @@ -18,19 +18,19 @@ * Mile data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Mile extends LengthUnit { - protected function configure () : void - { - $this - ->setName("mile") + protected function configure (): void + { + $this + ->setName("mile") - ->setSymbol("mi") + ->setSymbol("mi") - ->setUnits(1609.344) - ; - } + ->setUnits(1609.344) + ; + } } diff --git a/src/UnitConverter/Unit/Length/Milimeter.php b/src/UnitConverter/Unit/Length/Milimeter.php index 912738d5..6451984c 100644 --- a/src/UnitConverter/Unit/Length/Milimeter.php +++ b/src/UnitConverter/Unit/Length/Milimeter.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Length; @@ -18,19 +18,19 @@ * Milimeter data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Milimeter extends LengthUnit { - protected function configure () : void - { - $this - ->setName("milimeter") + protected function configure (): void + { + $this + ->setName("milimeter") - ->setSymbol("mm") + ->setSymbol("mm") - ->setUnits(0.001) - ; - } + ->setUnits(0.001) + ; + } } diff --git a/src/UnitConverter/Unit/Length/Nanometer.php b/src/UnitConverter/Unit/Length/Nanometer.php index 0efda50e..65d61068 100644 --- a/src/UnitConverter/Unit/Length/Nanometer.php +++ b/src/UnitConverter/Unit/Length/Nanometer.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Length; @@ -18,20 +18,20 @@ * Nanometer data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Nanometer extends LengthUnit { - protected function configure () : void - { - $this - ->setName("nanometer") + protected function configure (): void + { + $this + ->setName("nanometer") - ->setSymbol("nm") + ->setSymbol("nm") - # 1.0E-9 - ->setUnits(0.000000001) - ; - } + # 1.0E-9 + ->setUnits(0.000000001) + ; + } } diff --git a/src/UnitConverter/Unit/Length/Parsec.php b/src/UnitConverter/Unit/Length/Parsec.php index 9639f7ec..3e2012f0 100644 --- a/src/UnitConverter/Unit/Length/Parsec.php +++ b/src/UnitConverter/Unit/Length/Parsec.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Length; @@ -18,22 +18,22 @@ * Parsec data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Parsec extends LengthUnit { - protected function configure () : void - { - $this - ->setName("parsec") + protected function configure (): void + { + $this + ->setName("parsec") - ->setSymbol("pc") + ->setSymbol("pc") - # Metric (SI) Units = 3.0857×1016 m - # – OR – ~31 petametres - # 3.08567758149E+16 - ->setUnits(30856775814913672.789139379577965) - ; - } + # Metric (SI) Units = 3.0857×1016 m + # – OR – ~31 petametres + # 3.08567758149E+16 + ->setUnits(30856775814913672.789139379577965) + ; + } } diff --git a/src/UnitConverter/Unit/Length/Picometer.php b/src/UnitConverter/Unit/Length/Picometer.php index 8ea68c29..489c6736 100644 --- a/src/UnitConverter/Unit/Length/Picometer.php +++ b/src/UnitConverter/Unit/Length/Picometer.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Length; @@ -18,20 +18,20 @@ * Picometer data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Picometer extends LengthUnit { - protected function configure () : void - { - $this - ->setName("picometer") + protected function configure (): void + { + $this + ->setName("picometer") - ->setSymbol("pm") + ->setSymbol("pm") - # 1.0E-12 - ->setUnits(0.000000000001) - ; - } + # 1.0E-12 + ->setUnits(0.000000000001) + ; + } } diff --git a/src/UnitConverter/Unit/Length/Yard.php b/src/UnitConverter/Unit/Length/Yard.php index 5f80e474..835fd46c 100644 --- a/src/UnitConverter/Unit/Length/Yard.php +++ b/src/UnitConverter/Unit/Length/Yard.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Length; @@ -18,19 +18,19 @@ * Yard data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Yard extends LengthUnit { - protected function configure () : void - { - $this - ->setName("yard") + protected function configure (): void + { + $this + ->setName("yard") - ->setSymbol("yd") + ->setSymbol("yd") - ->setUnits(0.9144) - ; - } + ->setUnits(0.9144) + ; + } } diff --git a/src/UnitConverter/Unit/Mass/Gram.php b/src/UnitConverter/Unit/Mass/Gram.php index 9cb1cdfb..9901583c 100644 --- a/src/UnitConverter/Unit/Mass/Gram.php +++ b/src/UnitConverter/Unit/Mass/Gram.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Mass; @@ -18,19 +18,19 @@ * Gram data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Gram extends MassUnit { - protected function configure () : void - { - $this - ->setName("gram") + protected function configure (): void + { + $this + ->setName("gram") - ->setSymbol("g") + ->setSymbol("g") - ->setUnits(0.001) - ; - } + ->setUnits(0.001) + ; + } } diff --git a/src/UnitConverter/Unit/Mass/Kilogram.php b/src/UnitConverter/Unit/Mass/Kilogram.php index ab65b337..eb8ae44c 100644 --- a/src/UnitConverter/Unit/Mass/Kilogram.php +++ b/src/UnitConverter/Unit/Mass/Kilogram.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Mass; @@ -18,19 +18,19 @@ * Kilogram data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Kilogram extends MassUnit { - protected function configure () : void - { - $this - ->setName("kilogram") + protected function configure (): void + { + $this + ->setName("kilogram") - ->setSymbol("kg") + ->setSymbol("kg") - ->setUnits(1) - ; - } + ->setUnits(1) + ; + } } diff --git a/src/UnitConverter/Unit/Mass/MassUnit.php b/src/UnitConverter/Unit/Mass/MassUnit.php index 7c6495fd..46003a46 100644 --- a/src/UnitConverter/Unit/Mass/MassUnit.php +++ b/src/UnitConverter/Unit/Mass/MassUnit.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Mass; @@ -23,12 +23,12 @@ * overriding the $unitOf and $base properties only if necessary. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ abstract class MassUnit extends AbstractUnit { - protected $unitOf = Measure::MASS; + protected $unitOf = Measure::MASS; - protected $base = Kilogram::class; + protected $base = Kilogram::class; } diff --git a/src/UnitConverter/Unit/Mass/MetricTonne.php b/src/UnitConverter/Unit/Mass/MetricTonne.php index eed60b61..208834a6 100644 --- a/src/UnitConverter/Unit/Mass/MetricTonne.php +++ b/src/UnitConverter/Unit/Mass/MetricTonne.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Mass; @@ -18,19 +18,19 @@ * MetricTonne data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class MetricTonne extends MassUnit { - protected function configure () : void - { - $this - ->setName("metric tonne") + protected function configure (): void + { + $this + ->setName("metric tonne") - ->setSymbol("t") + ->setSymbol("t") - ->setUnits(1000) - ; - } + ->setUnits(1000) + ; + } } diff --git a/src/UnitConverter/Unit/Mass/Milligram.php b/src/UnitConverter/Unit/Mass/Milligram.php index 2d89983f..1269ad79 100644 --- a/src/UnitConverter/Unit/Mass/Milligram.php +++ b/src/UnitConverter/Unit/Mass/Milligram.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Mass; @@ -18,19 +18,19 @@ * Milligram data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Milligram extends MassUnit { - protected function configure () : void - { - $this - ->setName("milligram") + protected function configure (): void + { + $this + ->setName("milligram") - ->setSymbol("mg") + ->setSymbol("mg") - ->setUnits(0.000001) - ; - } + ->setUnits(0.000001) + ; + } } diff --git a/src/UnitConverter/Unit/Mass/Newton.php b/src/UnitConverter/Unit/Mass/Newton.php index 10653d43..40100833 100644 --- a/src/UnitConverter/Unit/Mass/Newton.php +++ b/src/UnitConverter/Unit/Mass/Newton.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Mass; @@ -18,19 +18,19 @@ * Newton data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Newton extends MassUnit { - protected function configure () : void - { - $this - ->setName("newton") + protected function configure (): void + { + $this + ->setName("newton") - ->setSymbol("N") + ->setSymbol("N") - ->setUnits(9.80665002863885) - ; - } + ->setUnits(9.80665002863885) + ; + } } diff --git a/src/UnitConverter/Unit/Mass/Ounce.php b/src/UnitConverter/Unit/Mass/Ounce.php index 8f0e0878..6eccd39f 100644 --- a/src/UnitConverter/Unit/Mass/Ounce.php +++ b/src/UnitConverter/Unit/Mass/Ounce.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Mass; @@ -18,19 +18,19 @@ * Ounce data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Ounce extends MassUnit { - protected function configure () : void - { - $this - ->setName("ounce") + protected function configure (): void + { + $this + ->setName("ounce") - ->setSymbol("oz") + ->setSymbol("oz") - ->setUnits(0.0283495) - ; - } + ->setUnits(0.0283495) + ; + } } diff --git a/src/UnitConverter/Unit/Mass/Pound.php b/src/UnitConverter/Unit/Mass/Pound.php index 879f1234..5223e502 100644 --- a/src/UnitConverter/Unit/Mass/Pound.php +++ b/src/UnitConverter/Unit/Mass/Pound.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Mass; @@ -18,19 +18,19 @@ * Pound data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Pound extends MassUnit { - protected function configure () : void - { - $this - ->setName("pound") + protected function configure (): void + { + $this + ->setName("pound") - ->setSymbol("lb") + ->setSymbol("lb") - ->setUnits(0.453592) - ; - } + ->setUnits(0.453592) + ; + } } diff --git a/src/UnitConverter/Unit/Mass/Stone.php b/src/UnitConverter/Unit/Mass/Stone.php index f0dc4de4..34094e30 100644 --- a/src/UnitConverter/Unit/Mass/Stone.php +++ b/src/UnitConverter/Unit/Mass/Stone.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Mass; @@ -18,12 +18,12 @@ * Stone data class. * * @version 1.0.0 - * @since 1.0.0 - * @author Jordan Brauer + * @since 0.3.9 + * @author Teun Willems */ class Stone extends MassUnit { - protected function configure () : void + protected function configure (): void { $this ->setName("stone") @@ -31,6 +31,6 @@ protected function configure () : void ->setSymbol("st") ->setUnits(6.35029) - ; + ; } } diff --git a/src/UnitConverter/Unit/Mass/UKLongTon.php b/src/UnitConverter/Unit/Mass/UKLongTon.php index a558bcb9..0c1fba2d 100644 --- a/src/UnitConverter/Unit/Mass/UKLongTon.php +++ b/src/UnitConverter/Unit/Mass/UKLongTon.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Mass; @@ -18,12 +18,12 @@ * UKLongTon data class. * * @version 1.0.0 - * @since 1.0.0 - * @author Jordan Brauer + * @since 0.3.9 + * @author Teun Willems */ class UKLongTon extends MassUnit { - protected function configure () : void + protected function configure (): void { $this ->setName("UK Long Ton") @@ -31,6 +31,6 @@ protected function configure () : void ->setSymbol("ukt") ->setUnits(2.204623) - ; + ; } } diff --git a/src/UnitConverter/Unit/Mass/USShortTon.php b/src/UnitConverter/Unit/Mass/USShortTon.php index 13756f92..7d66b3c0 100644 --- a/src/UnitConverter/Unit/Mass/USShortTon.php +++ b/src/UnitConverter/Unit/Mass/USShortTon.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Mass; @@ -18,12 +18,12 @@ * USShortTon data class. * * @version 1.0.0 - * @since 1.0.0 - * @author Jordan Brauer + * @since 0.3.9 + * @author Teun Willems */ class USShortTon extends MassUnit { - protected function configure () : void + protected function configure (): void { $this ->setName("US Short Ton") @@ -31,6 +31,6 @@ protected function configure () : void ->setSymbol("ust") ->setUnits(2.204623) - ; + ; } } diff --git a/src/UnitConverter/Unit/PlaneAngle/Degree.php b/src/UnitConverter/Unit/PlaneAngle/Degree.php index 9e86fd01..6db81b61 100644 --- a/src/UnitConverter/Unit/PlaneAngle/Degree.php +++ b/src/UnitConverter/Unit/PlaneAngle/Degree.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\PlaneAngle; @@ -18,19 +18,19 @@ * Degree unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Degree extends PlaneAngleUnit { - protected function configure () : void - { - $this - ->setName("degree") + protected function configure (): void + { + $this + ->setName("degree") - ->setSymbol("deg") + ->setSymbol("deg") - ->setUnits(1) - ; - } + ->setUnits(1) + ; + } } diff --git a/src/UnitConverter/Unit/PlaneAngle/PlaneAngleUnit.php b/src/UnitConverter/Unit/PlaneAngle/PlaneAngleUnit.php index 0a93da4d..9408a52f 100644 --- a/src/UnitConverter/Unit/PlaneAngle/PlaneAngleUnit.php +++ b/src/UnitConverter/Unit/PlaneAngle/PlaneAngleUnit.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\PlaneAngle; @@ -23,12 +23,12 @@ * overriding the $unitOf and $base properties only if necessary. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ abstract class PlaneAngleUnit extends AbstractUnit { - protected $unitOf = Measure::PLANE_ANGLE; + protected $unitOf = Measure::PLANE_ANGLE; - protected $base = Degree::class; + protected $base = Degree::class; } diff --git a/src/UnitConverter/Unit/PlaneAngle/Radian.php b/src/UnitConverter/Unit/PlaneAngle/Radian.php index a1647955..6097ab97 100644 --- a/src/UnitConverter/Unit/PlaneAngle/Radian.php +++ b/src/UnitConverter/Unit/PlaneAngle/Radian.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\PlaneAngle; @@ -18,19 +18,19 @@ * Radian unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Radian extends PlaneAngleUnit { - protected function configure () : void - { - $this - ->setName("radian") + protected function configure (): void + { + $this + ->setName("radian") - ->setSymbol("rad") + ->setSymbol("rad") - ->setUnits(57.2958) - ; - } + ->setUnits(57.2958) + ; + } } diff --git a/src/UnitConverter/Unit/Pressure/Atmosphere.php b/src/UnitConverter/Unit/Pressure/Atmosphere.php index 3c5dc5a5..67932f24 100644 --- a/src/UnitConverter/Unit/Pressure/Atmosphere.php +++ b/src/UnitConverter/Unit/Pressure/Atmosphere.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Pressure; @@ -18,19 +18,19 @@ * Atmosphere unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Atmosphere extends PressureUnit { - protected function configure () : void - { - $this - ->setName("atmosphere") + protected function configure (): void + { + $this + ->setName("atmosphere") - ->setSymbol("atm") + ->setSymbol("atm") - ->setUnits(101325) - ; - } + ->setUnits(101325) + ; + } } diff --git a/src/UnitConverter/Unit/Pressure/Bar.php b/src/UnitConverter/Unit/Pressure/Bar.php index b53685a8..6f18db61 100644 --- a/src/UnitConverter/Unit/Pressure/Bar.php +++ b/src/UnitConverter/Unit/Pressure/Bar.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Pressure; @@ -18,19 +18,19 @@ * Bar unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Bar extends PressureUnit { - protected function configure () : void - { - $this - ->setName("bar") + protected function configure (): void + { + $this + ->setName("bar") - ->setSymbol("bar") + ->setSymbol("bar") - ->setUnits(100000) - ; - } + ->setUnits(100000) + ; + } } diff --git a/src/UnitConverter/Unit/Pressure/Kilopascal.php b/src/UnitConverter/Unit/Pressure/Kilopascal.php index e343873d..338deff6 100644 --- a/src/UnitConverter/Unit/Pressure/Kilopascal.php +++ b/src/UnitConverter/Unit/Pressure/Kilopascal.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Pressure; @@ -18,19 +18,19 @@ * Kilopascal unit data class. * * @version 1.0.0 - * @since 1.0.0 - * @author Jordan Brauer + * @since 0.3.9 + * @author arubacao (https://github.com/arubacao) */ class Kilopascal extends PressureUnit { - protected function configure () : void - { - $this - ->setName("kilopascal") + protected function configure (): void + { + $this + ->setName("kilopascal") - ->setSymbol("kpa") + ->setSymbol("kpa") - ->setUnits(1000) - ; - } + ->setUnits(1000) + ; + } } diff --git a/src/UnitConverter/Unit/Pressure/Megapascal.php b/src/UnitConverter/Unit/Pressure/Megapascal.php index 4039c28c..cee51518 100644 --- a/src/UnitConverter/Unit/Pressure/Megapascal.php +++ b/src/UnitConverter/Unit/Pressure/Megapascal.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Pressure; @@ -18,19 +18,19 @@ * Megapascal unit data class. * * @version 1.0.0 - * @since 1.0.0 - * @author Jordan Brauer + * @since 0.3.9 + * @author arubacao (https://github.com/arubacao) */ class Megapascal extends PressureUnit { - protected function configure () : void - { - $this - ->setName("megapascal") + protected function configure (): void + { + $this + ->setName("megapascal") - ->setSymbol("mpa") + ->setSymbol("mpa") - ->setUnits(1000000) - ; - } + ->setUnits(1000000) + ; + } } diff --git a/src/UnitConverter/Unit/Pressure/Millibar.php b/src/UnitConverter/Unit/Pressure/Millibar.php index a78be420..a632d420 100644 --- a/src/UnitConverter/Unit/Pressure/Millibar.php +++ b/src/UnitConverter/Unit/Pressure/Millibar.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Pressure; @@ -18,12 +18,12 @@ * Millibar unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.3.9 * @author Teun Willems */ class Millibar extends PressureUnit { - protected function configure () : void + protected function configure (): void { $this ->setName("millibar") @@ -31,6 +31,6 @@ protected function configure () : void ->setSymbol("mbar") ->setUnits(100) - ; + ; } } diff --git a/src/UnitConverter/Unit/Pressure/Pascal.php b/src/UnitConverter/Unit/Pressure/Pascal.php index 3eed42f7..a8405448 100644 --- a/src/UnitConverter/Unit/Pressure/Pascal.php +++ b/src/UnitConverter/Unit/Pressure/Pascal.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Pressure; @@ -18,19 +18,19 @@ * Pascal unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Pascal extends PressureUnit { - protected function configure () : void - { - $this - ->setName("pascal") + protected function configure (): void + { + $this + ->setName("pascal") - ->setSymbol("pa") + ->setSymbol("pa") - ->setUnits(1) - ; - } + ->setUnits(1) + ; + } } diff --git a/src/UnitConverter/Unit/Pressure/PoundForcePerSquareInch.php b/src/UnitConverter/Unit/Pressure/PoundForcePerSquareInch.php index 7c2bc89b..0fa18a4d 100644 --- a/src/UnitConverter/Unit/Pressure/PoundForcePerSquareInch.php +++ b/src/UnitConverter/Unit/Pressure/PoundForcePerSquareInch.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Pressure; @@ -18,19 +18,19 @@ * PoundForcePerSquareInch unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class PoundForcePerSquareInch extends PressureUnit { - protected function configure () : void - { - $this - ->setName("pound-force per square inch") + protected function configure (): void + { + $this + ->setName("pound-force per square inch") - ->setSymbol("psi") + ->setSymbol("psi") - ->setUnits(6894.76) - ; - } + ->setUnits(6894.76) + ; + } } diff --git a/src/UnitConverter/Unit/Pressure/PressureUnit.php b/src/UnitConverter/Unit/Pressure/PressureUnit.php index 318509ea..d4b8e365 100644 --- a/src/UnitConverter/Unit/Pressure/PressureUnit.php +++ b/src/UnitConverter/Unit/Pressure/PressureUnit.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Pressure; @@ -28,7 +28,7 @@ */ abstract class PressureUnit extends AbstractUnit { - protected $unitOf = Measure::PRESSURE; + protected $unitOf = Measure::PRESSURE; - protected $base = Pascal::class; + protected $base = Pascal::class; } diff --git a/src/UnitConverter/Unit/Pressure/Torr.php b/src/UnitConverter/Unit/Pressure/Torr.php index d6e7f43a..224fa2c1 100644 --- a/src/UnitConverter/Unit/Pressure/Torr.php +++ b/src/UnitConverter/Unit/Pressure/Torr.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Pressure; @@ -23,14 +23,14 @@ */ class Torr extends PressureUnit { - protected function configure () : void - { - $this - ->setName("torr") + protected function configure (): void + { + $this + ->setName("torr") - ->setSymbol("Torr") + ->setSymbol("Torr") - ->setUnits(133.322) - ; - } + ->setUnits(133.322) + ; + } } diff --git a/src/UnitConverter/Unit/Speed/KilometrePerHour.php b/src/UnitConverter/Unit/Speed/KilometrePerHour.php index 36f9248f..a295e4c6 100644 --- a/src/UnitConverter/Unit/Speed/KilometrePerHour.php +++ b/src/UnitConverter/Unit/Speed/KilometrePerHour.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Speed; @@ -18,19 +18,19 @@ * Kilometre per hour unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class KilometrePerHour extends SpeedUnit { - protected function configure () : void - { - $this - ->setName("kilometre per hour") + protected function configure (): void + { + $this + ->setName("kilometre per hour") - ->setSymbol("kph") + ->setSymbol("kph") - ->setUnits(0.277778) - ; - } + ->setUnits(0.277778) + ; + } } diff --git a/src/UnitConverter/Unit/Speed/MetrePerSecond.php b/src/UnitConverter/Unit/Speed/MetrePerSecond.php index 6e50ab39..e6985fab 100644 --- a/src/UnitConverter/Unit/Speed/MetrePerSecond.php +++ b/src/UnitConverter/Unit/Speed/MetrePerSecond.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Speed; @@ -18,19 +18,19 @@ * MetrePerSecond unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class MetrePerSecond extends SpeedUnit { - protected function configure () : void - { - $this - ->setName("metre per second") + protected function configure (): void + { + $this + ->setName("metre per second") - ->setSymbol("mps") + ->setSymbol("mps") - ->setUnits(1) - ; - } + ->setUnits(1) + ; + } } diff --git a/src/UnitConverter/Unit/Speed/MilesPerHour.php b/src/UnitConverter/Unit/Speed/MilesPerHour.php index 6c553b14..43276e51 100644 --- a/src/UnitConverter/Unit/Speed/MilesPerHour.php +++ b/src/UnitConverter/Unit/Speed/MilesPerHour.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Speed; @@ -18,19 +18,19 @@ * Miles per hour unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class MilesPerHour extends SpeedUnit { - protected function configure () : void - { - $this - ->setName("miles per hour") + protected function configure (): void + { + $this + ->setName("miles per hour") - ->setSymbol("mph") + ->setSymbol("mph") - ->setUnits(0.44704) - ; - } + ->setUnits(0.44704) + ; + } } diff --git a/src/UnitConverter/Unit/Speed/SpeedUnit.php b/src/UnitConverter/Unit/Speed/SpeedUnit.php index ce7f501e..f6dc9e1c 100644 --- a/src/UnitConverter/Unit/Speed/SpeedUnit.php +++ b/src/UnitConverter/Unit/Speed/SpeedUnit.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Speed; @@ -23,12 +23,12 @@ * overriding the $unitOf and $base properties only if necessary. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ abstract class SpeedUnit extends AbstractUnit { - protected $unitOf = Measure::SPEED; + protected $unitOf = Measure::SPEED; - protected $base = MetrePerSecond::class; + protected $base = MetrePerSecond::class; } diff --git a/src/UnitConverter/Unit/Temperature/Celsius.php b/src/UnitConverter/Unit/Temperature/Celsius.php index 86adbdcd..ad6966fd 100644 --- a/src/UnitConverter/Unit/Temperature/Celsius.php +++ b/src/UnitConverter/Unit/Temperature/Celsius.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Temperature; @@ -22,49 +22,49 @@ * Celsius unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Celsius extends TemperatureUnit { - protected function configure () : void - { - $this - ->setName("celsius") + protected function configure (): void + { + $this + ->setName("celsius") - ->setSymbol("c") - ; - } + ->setSymbol("c") + ; + } - protected function calculate (CalculatorInterface $calculator, $value, UnitInterface $to, int $percision = null) - { - $val = $value ?? $this->getBasetUnits(); + protected function calculate (CalculatorInterface $calculator, $value, UnitInterface $to, int $precision = null) + { + $val = $value ?? $this->getBasetUnits(); - # 0 °K = 273.15 °C - switch ($to->getSymbol()) { - case 'f': # °F = (°C × (9 ÷ 5)) + 32 - return $calculator->round( - $calculator->add( - $calculator->mul($val, $calculator->div(9, 5)), - 32 - ), - $percision - ); - break; + # 0 °K = 273.15 °C + switch ($to->getSymbol()) { + case 'f': # °F = (°C × (9 ÷ 5)) + 32 + return $calculator->round( + $calculator->add( + $calculator->mul($val, $calculator->div(9, 5)), + 32 + ), + $precision + ); + break; - case 'k': # °K = °C + 273.15 - return $calculator->round( - $calculator->add($val, 273.15), - $percision - ); - break; + case 'k': # °K = °C + 273.15 + return $calculator->round( + $calculator->add($val, 273.15), + $precision + ); + break; - case 'c': # °C = °C - return $val; - break; + case 'c': # °C = °C + return $val; + break; - default: - throw new Exception("Unknown conversion formula for {$to->getSymbol()}"); + default: + throw new Exception("Unknown conversion formula for {$to->getSymbol()}"); + } + } } - } -} diff --git a/src/UnitConverter/Unit/Temperature/Fahrenheit.php b/src/UnitConverter/Unit/Temperature/Fahrenheit.php index f6d165c1..ebdced0e 100644 --- a/src/UnitConverter/Unit/Temperature/Fahrenheit.php +++ b/src/UnitConverter/Unit/Temperature/Fahrenheit.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Temperature; @@ -22,52 +22,52 @@ * Fahrenheit unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Fahrenheit extends TemperatureUnit { - protected function configure () : void - { - $this - ->setName("fahrenheit") + protected function configure (): void + { + $this + ->setName("fahrenheit") - ->setSymbol("f") - ; - } + ->setSymbol("f") + ; + } - protected function calculate (CalculatorInterface $calculator, $value, UnitInterface $to, int $percision = null) - { - $val = $value ?? $this->getBase()->getUnits(); + protected function calculate (CalculatorInterface $calculator, $value, UnitInterface $to, int $precision = null) + { + $val = $value ?? $this->getBase()->getUnits(); - # 0 °K = 255.372 °F - switch ($to->getSymbol()) { - case 'c': # °C = (°F - 32) × (5 ÷ 9) - return $calculator->round( - $calculator->mul( - $calculator->sub($val, 32), - $calculator->div(5, 9) - ), - $percision - ); - break; + # 0 °K = 255.372 °F + switch ($to->getSymbol()) { + case 'c': # °C = (°F - 32) × (5 ÷ 9) + return $calculator->round( + $calculator->mul( + $calculator->sub($val, 32), + $calculator->div(5, 9) + ), + $precision + ); + break; - case 'k': # °K = (°F + 459.67) × (5 ÷ 9) - return $calculator->round( - $calculator->mul( - $calculator->add($val, 459.67), - $calculator->div(5, 9) - ), - $percision - ); - break; + case 'k': # °K = (°F + 459.67) × (5 ÷ 9) + return $calculator->round( + $calculator->mul( + $calculator->add($val, 459.67), + $calculator->div(5, 9) + ), + $precision + ); + break; - case 'f': # °F = °F - return $val; - break; + case 'f': # °F = °F + return $val; + break; - default: - throw new Exception("Unknown conversion formula for {$to->getSymbol()}"); + default: + throw new Exception("Unknown conversion formula for {$to->getSymbol()}"); + } + } } - } -} diff --git a/src/UnitConverter/Unit/Temperature/Kelvin.php b/src/UnitConverter/Unit/Temperature/Kelvin.php index f29d951b..cb1fc150 100644 --- a/src/UnitConverter/Unit/Temperature/Kelvin.php +++ b/src/UnitConverter/Unit/Temperature/Kelvin.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Temperature; @@ -18,19 +18,19 @@ * Kelvin unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Kelvin extends TemperatureUnit { - protected function configure () : void - { - $this - ->setName("kelvin") + protected function configure (): void + { + $this + ->setName("kelvin") - ->setSymbol("k") + ->setSymbol("k") - ->setUnits(1) - ; - } + ->setUnits(1) + ; + } } diff --git a/src/UnitConverter/Unit/Temperature/TemperatureUnit.php b/src/UnitConverter/Unit/Temperature/TemperatureUnit.php index 042d04ab..065395dd 100644 --- a/src/UnitConverter/Unit/Temperature/TemperatureUnit.php +++ b/src/UnitConverter/Unit/Temperature/TemperatureUnit.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Temperature; @@ -23,12 +23,12 @@ * overriding the $unitOf and $base properties only if necessary. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ abstract class TemperatureUnit extends AbstractUnit { - protected $unitOf = Measure::TEMPERATURE; + protected $unitOf = Measure::TEMPERATURE; - protected $base = Kelvin::class; + protected $base = Kelvin::class; } diff --git a/src/UnitConverter/Unit/Time/Day.php b/src/UnitConverter/Unit/Time/Day.php index c61dba73..40be7c48 100644 --- a/src/UnitConverter/Unit/Time/Day.php +++ b/src/UnitConverter/Unit/Time/Day.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Time; @@ -18,12 +18,12 @@ * Day unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.3.9 * @author Teun Willems */ class Day extends TimeUnit { - protected function configure () : void + protected function configure (): void { $this ->setName("day") @@ -31,6 +31,6 @@ protected function configure () : void ->setSymbol("day") ->setUnits(86400) - ; + ; } } diff --git a/src/UnitConverter/Unit/Time/Hour.php b/src/UnitConverter/Unit/Time/Hour.php index 6867427d..d2936e6a 100644 --- a/src/UnitConverter/Unit/Time/Hour.php +++ b/src/UnitConverter/Unit/Time/Hour.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Time; @@ -18,12 +18,12 @@ * Hour unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.3.9 * @author Teun Willems */ class Hour extends TimeUnit { - protected function configure () : void + protected function configure (): void { $this ->setName("hour") @@ -31,6 +31,6 @@ protected function configure () : void ->setSymbol("hr") ->setUnits(3600) - ; + ; } } diff --git a/src/UnitConverter/Unit/Time/Microsecond.php b/src/UnitConverter/Unit/Time/Microsecond.php index f6e84cea..71c6d922 100644 --- a/src/UnitConverter/Unit/Time/Microsecond.php +++ b/src/UnitConverter/Unit/Time/Microsecond.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Time; @@ -18,12 +18,12 @@ * Microsecond unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.3.9 * @author Teun Willems */ class Microsecond extends TimeUnit { - protected function configure () : void + protected function configure (): void { $this ->setName("microsecond") @@ -31,6 +31,6 @@ protected function configure () : void ->setSymbol("μs") ->setUnits(0.000001) - ; + ; } } diff --git a/src/UnitConverter/Unit/Time/Millisecond.php b/src/UnitConverter/Unit/Time/Millisecond.php index 54842346..b8dc6f8e 100644 --- a/src/UnitConverter/Unit/Time/Millisecond.php +++ b/src/UnitConverter/Unit/Time/Millisecond.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Time; @@ -18,12 +18,12 @@ * Millisecond unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.3.9 * @author Teun Willems */ class Millisecond extends TimeUnit { - protected function configure () : void + protected function configure (): void { $this ->setName("millisecond") @@ -31,6 +31,6 @@ protected function configure () : void ->setSymbol("ms") ->setUnits(0.001) - ; + ; } } diff --git a/src/UnitConverter/Unit/Time/Minute.php b/src/UnitConverter/Unit/Time/Minute.php index 9fe1b75b..a821a5ef 100644 --- a/src/UnitConverter/Unit/Time/Minute.php +++ b/src/UnitConverter/Unit/Time/Minute.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Time; @@ -18,12 +18,12 @@ * Minute unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.3.9 * @author Teun Willems */ class Minute extends TimeUnit { - protected function configure () : void + protected function configure (): void { $this ->setName("minute") @@ -31,6 +31,6 @@ protected function configure () : void ->setSymbol("min") ->setUnits(60) - ; + ; } } diff --git a/src/UnitConverter/Unit/Time/Month.php b/src/UnitConverter/Unit/Time/Month.php index 4eabccf5..d7c25236 100644 --- a/src/UnitConverter/Unit/Time/Month.php +++ b/src/UnitConverter/Unit/Time/Month.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Time; @@ -18,12 +18,12 @@ * Month unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.3.9 * @author Teun Willems */ class Month extends TimeUnit { - protected function configure () : void + protected function configure (): void { $this ->setName("month") @@ -31,6 +31,6 @@ protected function configure () : void ->setSymbol("month") ->setUnits(2678400) - ; + ; } } diff --git a/src/UnitConverter/Unit/Time/Nanosecond.php b/src/UnitConverter/Unit/Time/Nanosecond.php index cfdde003..345226ea 100644 --- a/src/UnitConverter/Unit/Time/Nanosecond.php +++ b/src/UnitConverter/Unit/Time/Nanosecond.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Time; @@ -18,12 +18,12 @@ * Nanosecond unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.3.9 * @author Teun Willems */ class Nanosecond extends TimeUnit { - protected function configure () : void + protected function configure (): void { $this ->setName("nanosecond") @@ -31,6 +31,6 @@ protected function configure () : void ->setSymbol("ns") ->setUnits(0.000000001) - ; + ; } } diff --git a/src/UnitConverter/Unit/Time/Second.php b/src/UnitConverter/Unit/Time/Second.php index 3ad81e59..2f85b877 100644 --- a/src/UnitConverter/Unit/Time/Second.php +++ b/src/UnitConverter/Unit/Time/Second.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Time; @@ -18,12 +18,12 @@ * Second unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.3.9 * @author Teun Willems */ class Second extends TimeUnit { - protected function configure () : void + protected function configure (): void { $this ->setName("second") @@ -31,6 +31,6 @@ protected function configure () : void ->setSymbol("s") ->setUnits(1) - ; + ; } } diff --git a/src/UnitConverter/Unit/Time/TimeUnit.php b/src/UnitConverter/Unit/Time/TimeUnit.php index 7fbc6f54..fe171e72 100644 --- a/src/UnitConverter/Unit/Time/TimeUnit.php +++ b/src/UnitConverter/Unit/Time/TimeUnit.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Time; @@ -23,7 +23,7 @@ * Only override $unitOf and $base properties when necessary * * @version 1.0.0 - * @since 1.0.0 + * @since 0.3.9 * @author Teun Willems */ abstract class TimeUnit extends AbstractUnit @@ -31,4 +31,4 @@ abstract class TimeUnit extends AbstractUnit protected $unitOf = Measure::TIME; protected $base = Second::class; -} \ No newline at end of file +} diff --git a/src/UnitConverter/Unit/Time/Week.php b/src/UnitConverter/Unit/Time/Week.php index 691a3af8..ef2145fa 100644 --- a/src/UnitConverter/Unit/Time/Week.php +++ b/src/UnitConverter/Unit/Time/Week.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Time; @@ -18,12 +18,12 @@ * Week unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.3.9 * @author Teun Willems */ class Week extends TimeUnit { - protected function configure () : void + protected function configure (): void { $this ->setName("week") @@ -31,6 +31,6 @@ protected function configure () : void ->setSymbol("week") ->setUnits(604800) - ; + ; } } diff --git a/src/UnitConverter/Unit/Time/Year.php b/src/UnitConverter/Unit/Time/Year.php index 8f99063f..b5203203 100644 --- a/src/UnitConverter/Unit/Time/Year.php +++ b/src/UnitConverter/Unit/Time/Year.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Time; @@ -18,12 +18,12 @@ * Year unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.3.9 * @author Teun Willems */ class Year extends TimeUnit { - protected function configure () : void + protected function configure (): void { $this ->setName("year") @@ -31,6 +31,6 @@ protected function configure () : void ->setSymbol("year") ->setUnits(31536000) - ; + ; } } diff --git a/src/UnitConverter/Unit/UnitInterface.php b/src/UnitConverter/Unit/UnitInterface.php index e9593fcd..1671adaf 100644 --- a/src/UnitConverter/Unit/UnitInterface.php +++ b/src/UnitConverter/Unit/UnitInterface.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit; @@ -18,107 +18,107 @@ * Interface for the unit of measurement abstract class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ interface UnitInterface { - /** - * Sets the units full symantic name. - * - * @param string $name The value to be set as the units name - * @return UnitInterface - */ - public function setName (string $name) : UnitInterface; - - /** - * Returns the full symantic name of the unit. - * - * @return string - */ - public function getName () : string; - - /** - * Sets the symbol notation used for the unit. - * - * @param string $symbol The value to be set as the units symbol - * @return UnitInterface - */ - public function setSymbol (string $symbol) : UnitInterface; - - /** - * Returns the symbol notation of the unit. - * - * @return string - */ - public function getSymbol () : string; - - /** - * Sets the unicode scientific symbol notation used for the unit. - * - * @param string $scientificSymbol The unicode character to be set as the units scientific symbol - * @return UnitInterface - */ - public function setScientificSymbol (string $scientificSymbol) : UnitInterface; - - /** - * Returns the symbol notation of the unit. - * - * @return string - */ - public function getScientificSymbol () : string; - - /** - * Sets the type of measurement that this unit is measuring. - * - * @param string $unitOf The value to be set as the units governing unit - * @return UnitInterface - */ - public function setUnitOf (string $unitOf) : UnitInterface; - - /** - * Returns the type of measurement that this unit is measuring. - * - * @return string - */ - public function getUnitOf () : string; - - /** - * Sets the unit class that this unit is based off of. - * - * @param mixed $base The class that the unit is based on. - * @return UnitInterface - * - * @example $this->setBase(Volume::class); - */ - public function setBase ($base) : UnitInterface; - - /** - * Returns the unit class that this unit is based off of. - * - * @return UnitInterface - */ - public function getBase () : UnitInterface; - - /** - * Sets the amount of base units required to make up 1 of the unit. - * - * @param float $units The amount of units required to make a single base unit - * @return UnitInterface - */ - public function setUnits (float $units) : UnitInterface; - - /** - * Returns the amount of base units required to make up 1 of the unit. - * - * @return float - */ - public function getUnits () : float; - - /** - * Returns the units base unit units'. - * - * @return float - */ - public function getBaseUnits () : float; + /** + * Sets the units full symantic name. + * + * @param string $name The value to be set as the units name + * @return UnitInterface + */ + public function setName (string $name): UnitInterface; + + /** + * Returns the full symantic name of the unit. + * + * @return string + */ + public function getName (): string; + + /** + * Sets the symbol notation used for the unit. + * + * @param string $symbol The value to be set as the units symbol + * @return UnitInterface + */ + public function setSymbol (string $symbol): UnitInterface; + + /** + * Returns the symbol notation of the unit. + * + * @return string + */ + public function getSymbol (): string; + + /** + * Sets the unicode scientific symbol notation used for the unit. + * + * @param string $scientificSymbol The unicode character to be set as the units scientific symbol + * @return UnitInterface + */ + public function setScientificSymbol (string $scientificSymbol): UnitInterface; + + /** + * Returns the symbol notation of the unit. + * + * @return string + */ + public function getScientificSymbol (): string; + + /** + * Sets the type of measurement that this unit is measuring. + * + * @param string $unitOf The value to be set as the units governing unit + * @return UnitInterface + */ + public function setUnitOf (string $unitOf): UnitInterface; + + /** + * Returns the type of measurement that this unit is measuring. + * + * @return string + */ + public function getUnitOf (): string; + + /** + * Sets the unit class that this unit is based off of. + * + * @param mixed $base The class that the unit is based on. + * @return UnitInterface + * + * @example $this->setBase(Volume::class); + */ + public function setBase ($base): UnitInterface; + + /** + * Returns the unit class that this unit is based off of. + * + * @return UnitInterface + */ + public function getBase (): UnitInterface; + + /** + * Sets the amount of base units required to make up 1 of the unit. + * + * @param float $units The amount of units required to make a single base unit + * @return UnitInterface + */ + public function setUnits (float $units): UnitInterface; + + /** + * Returns the amount of base units required to make up 1 of the unit. + * + * @return float + */ + public function getUnits (): float; + + /** + * Returns the units base unit units'. + * + * @return float + */ + public function getBaseUnits (): float; } diff --git a/src/UnitConverter/Unit/Volume/CubicMetre.php b/src/UnitConverter/Unit/Volume/CubicMetre.php index ddbc0b83..84490189 100644 --- a/src/UnitConverter/Unit/Volume/CubicMetre.php +++ b/src/UnitConverter/Unit/Volume/CubicMetre.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Volume; @@ -18,19 +18,19 @@ * Cubic metre unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class CubicMetre extends VolumeUnit { - protected function configure () : void - { - $this - ->setName("cubic metre") + protected function configure (): void + { + $this + ->setName("cubic metre") - ->setSymbol("m3") + ->setSymbol("m3") - ->setUnits(1000) - ; - } + ->setUnits(1000) + ; + } } diff --git a/src/UnitConverter/Unit/Volume/Gallon.php b/src/UnitConverter/Unit/Volume/Gallon.php index b97146fe..5cf573eb 100644 --- a/src/UnitConverter/Unit/Volume/Gallon.php +++ b/src/UnitConverter/Unit/Volume/Gallon.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Volume; @@ -18,19 +18,19 @@ * Gallon unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Gallon extends VolumeUnit { - protected function configure () : void - { - $this - ->setName("gallon") + protected function configure (): void + { + $this + ->setName("gallon") - ->setSymbol("gal") + ->setSymbol("gal") - ->setUnits(3.78541) - ; - } + ->setUnits(3.78541) + ; + } } diff --git a/src/UnitConverter/Unit/Volume/Litre.php b/src/UnitConverter/Unit/Volume/Litre.php index 7550fa8e..98dcc933 100644 --- a/src/UnitConverter/Unit/Volume/Litre.php +++ b/src/UnitConverter/Unit/Volume/Litre.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Volume; @@ -18,19 +18,19 @@ * Litre unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Litre extends VolumeUnit { - protected function configure () : void - { - $this - ->setName("litre") + protected function configure (): void + { + $this + ->setName("litre") - ->setSymbol("l") + ->setSymbol("l") - ->setUnits(1) - ; - } + ->setUnits(1) + ; + } } diff --git a/src/UnitConverter/Unit/Volume/Mililitre.php b/src/UnitConverter/Unit/Volume/Mililitre.php index 31df701c..16f38d6b 100644 --- a/src/UnitConverter/Unit/Volume/Mililitre.php +++ b/src/UnitConverter/Unit/Volume/Mililitre.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Volume; @@ -18,19 +18,19 @@ * Mililitre unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Mililitre extends VolumeUnit { - protected function configure () : void - { - $this - ->setName("mililitre") + protected function configure (): void + { + $this + ->setName("mililitre") - ->setSymbol("ml") + ->setSymbol("ml") - ->setUnits(0.001) - ; - } + ->setUnits(0.001) + ; + } } diff --git a/src/UnitConverter/Unit/Volume/Pint.php b/src/UnitConverter/Unit/Volume/Pint.php index 043bb66d..d8a9d480 100644 --- a/src/UnitConverter/Unit/Volume/Pint.php +++ b/src/UnitConverter/Unit/Volume/Pint.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Volume; @@ -18,19 +18,19 @@ * Pint unit data class. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class Pint extends VolumeUnit { - protected function configure () : void - { - $this - ->setName("pint") + protected function configure (): void + { + $this + ->setName("pint") - ->setSymbol("pt") + ->setSymbol("pt") - ->setUnits(0.473176) - ; - } + ->setUnits(0.473176) + ; + } } diff --git a/src/UnitConverter/Unit/Volume/VolumeUnit.php b/src/UnitConverter/Unit/Volume/VolumeUnit.php index ad0d9077..e2779fc3 100644 --- a/src/UnitConverter/Unit/Volume/VolumeUnit.php +++ b/src/UnitConverter/Unit/Volume/VolumeUnit.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Unit\Volume; @@ -23,12 +23,12 @@ * overriding the $unitOf and $base properties only if necessary. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ abstract class VolumeUnit extends AbstractUnit { - protected $unitOf = Measure::VOLUME; + protected $unitOf = Measure::VOLUME; - protected $base = Litre::class; + protected $base = Litre::class; } diff --git a/src/UnitConverter/UnitConverter.php b/src/UnitConverter/UnitConverter.php index 4e8b1c2b..b9b9d925 100644 --- a/src/UnitConverter/UnitConverter.php +++ b/src/UnitConverter/UnitConverter.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter; @@ -21,186 +21,194 @@ use UnitConverter\Unit\UnitInterface; /** - * The actual unit converter object. + * The actual unit converter object. Extend this object + * if you would like to implement your own custom converter. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ class UnitConverter implements UnitConverterInterface { - /** - * @var UnitRegistryInterface $registry The registry that the unit converter accesses available units from - */ - protected $registry; - - /** - * @var CalculatorInterface $calculator The converters internal calculator used to handle mathematical operations - */ - protected $calculator; - - /** - * @var float $convert The value being converted. - */ - protected $convert; - - /** - * @var string $from The unit of measure being converted **from**. - */ - protected $from; - - /** - * @var string $to The unit of measure being converted **to**. - */ - protected $to; - - /** - * @var int $percision The decimal precision to be calculated - */ - protected $percision; - - /** - * Public constructor function for the UnitConverter class. - * - * @param UnitInterface[] $registry A two-dimensional array of UnitInterface objects. - * @return self - */ - public function __construct (UnitRegistryInterface $registry, CalculatorInterface $calculator) - { - $this->setRegistry($registry); - $this->setCalculator($calculator); - } - - public function convert ($value, int $percision = null) - { - $this->percision = $percision; - $this->convert = $value; - return $this; - } - - public function from (string $unit) - { - $this->from = $this->loadUnit($unit); - return $this; - } - - public function to (string $unit) - { - $this->to = $this->loadUnit($unit); - return $this->calculate( - $this->calculator, - $this->convert, - $this->from, - $this->to, - $this->percision - ); - } - - /** - * Calculate the conversion from one unit to another. - * - * @FIXME Gross use of a check for a null calculate() method ... 😑 Gotta - * figure out a better way to use the calulate method. - * - * @internal - * @throws MissingCalculatorException - * @param CalculatorInterface $calculator $The calculator being used to - * @param int|float|string $value The initial value being converted. - * @param UnitInterface $from The unit of measure being converted **from**. - * @param UnitInterface $to The unit of measure being converted **to**. - * @param int $percision The decimal percision to be calculated - * @return int|float|string - */ - protected function calculate ( - CalculatorInterface $calculator, - $value, - UnitInterface $from, - UnitInterface $to, - int $percision = null - ) { - $selfConversion = $from->convert($calculator, $value, $to, $percision); - - if ($selfConversion) - return $selfConversion; - - if ($this->calculatorExists() === false) - throw new MissingCalculatorException("No calculator was found to perform mathematical operations with."); - - # If the unit does not implement the calculate() method, convert it manually. - return $calculator->round( - $calculator->div( - $calculator->mul($value, $from->getUnits()), - $to->getUnits() - ), - $percision - ); - } - - /** - * Load a unit from the unit converter registry. - * - * @internal - * @uses UnitConverter\UnitRegistry::loadUnit - * @throws MissingUnitRegistryException An out of bounds exception will be thrown if an attempt is made to access a non-existent registry. - * @return UnitInterface - */ - protected function loadUnit(string $symbol): UnitInterface - { - if ($this->registryExists() === false) - throw new MissingUnitRegistryException("No unit registry was found to load units from."); - - return $this->registry->loadUnit($symbol); - } - - /** - * Set the unit converter registry for storing units of measure to convert values with. - * - * @api - * @param UnitRegistryInterface $registry An instance of UnitRegistry. - */ - public function setRegistry (UnitRegistryInterface $registry): UnitConverterInterface - { - $this->registry = $registry; - return $this; - } - - /** - * Set the unit converter calculator to perform mathematical operations with. - * - * @api - * @param CalculatorInterface $calculator An instance of a CalculatorInterface - */ - public function setCalculator (CalculatorInterface $calculator): UnitConverterInterface - { - $this->calculator = $calculator; - return $this; - } - - /** - * Determine whether or not the converter has an active registry. - * - * @internal - * @return bool - */ - protected function registryExists (): bool - { - if ($this->registry instanceof UnitRegistryInterface) - return true; - - return false; - } - - /** - * Determine whether or not the converter has an active calculator. - * - * @internal - * @return bool - */ - protected function calculatorExists (): bool - { - if ($this->calculator instanceof CalculatorInterface) - return true; - - return false; - } + /** + * @var UnitRegistryInterface $registry The registry that the unit converter accesses available units from + */ + protected $registry; + + /** + * @var CalculatorInterface $calculator The converters internal calculator used to handle mathematical operations + */ + protected $calculator; + + /** + * @var float $convert The value being converted. + */ + protected $convert; + + /** + * @var string $from The unit of measure being converted **from**. + */ + protected $from; + + /** + * @var string $to The unit of measure being converted **to**. + */ + protected $to; + + /** + * @var int $precision The decimal precision to be calculated + */ + protected $precision; + + /** + * Public constructor function for the UnitConverter class. + * + * @param UnitInterface[] $registry A two-dimensional array of UnitInterface objects. + * @param CalculatorInterface $calculator The calculator that the converter will use to perform mathematical operations. + */ + public function __construct (UnitRegistryInterface $registry, CalculatorInterface $calculator) + { + $this->setRegistry($registry); + $this->setCalculator($calculator); + } + + /** + * Set the unit converter registry for storing units of measure to convert values with. + * + * @api + * @param UnitRegistryInterface $registry An instance of UnitRegistry. + * @return UnitConverterInterface + */ + public function setRegistry (UnitRegistryInterface $registry): UnitConverterInterface + { + $this->registry = $registry; + return $this; + } + + /** + * Set the unit converter calculator to perform mathematical operations with. + * + * @api + * @param CalculatorInterface $calculator An instance of a CalculatorInterface + * @return UnitConverterInterface + */ + public function setCalculator (CalculatorInterface $calculator): UnitConverterInterface + { + $this->calculator = $calculator; + return $this; + } + + public function convert ($value, int $precision = null): UnitConverterInterface + { + $this->percision = $precision; + $this->convert = $value; + return $this; + } + + public function from (string $unit): UnitConverterInterface + { + $this->from = $this->loadUnit($unit); + return $this; + } + + public function to (string $unit) + { + $this->to = $this->loadUnit($unit); + return $this->calculate( + $this->calculator, + $this->convert, + $this->from, + $this->to, + $this->percision + ); + } + + /** + * Calculate the conversion from one unit to another. + * + * @FIXME Gross use of a check for a null calculate() method ... 😑 Gotta + * figure out a better way to use the calulate method. + * + * @internal + * + * @param CalculatorInterface $calculator $The calculator being used to + * @param int|float|string $value The initial value being converted. + * @param UnitInterface $from The unit of measure being converted **from**. + * @param UnitInterface $to The unit of measure being converted **to**. + * @param int $precision The decimal percision to be calculated + * + * @return int|float|string + * @throws MissingCalculatorException + */ + protected function calculate ( + CalculatorInterface $calculator, + $value, + UnitInterface $from, + UnitInterface $to, + int $precision = null + ) { + $selfConversion = $from->convert($calculator, $value, $to, $precision); + + if ($selfConversion) + return $selfConversion; + + if ($this->calculatorExists() === false) + throw new MissingCalculatorException("No calculator was found to perform mathematical operations with."); + + # If the unit does not implement the calculate() method, convert it manually. + return $calculator->round( + $calculator->div( + $calculator->mul($value, $from->getUnits()), + $to->getUnits() + ), + $precision + ); + } + + /** + * Load a unit from the unit converter registry. + * + * @internal + * @uses UnitConverter\UnitRegistry::loadUnit + * + * @param string $symbol The symbol of the unit being loaded. + * + * @return UnitInterface + * @throws MissingUnitRegistryException Thrown if an attempt is made to access a non-existent registry. + */ + protected function loadUnit(string $symbol): UnitInterface + { + if ($this->registryExists() === false) + throw new MissingUnitRegistryException("No unit registry was found to load units from."); + + return $this->registry->loadUnit($symbol); + } + + /** + * Determine whether or not the converter has an active registry. + * + * @internal + * @return bool + */ + protected function registryExists (): bool + { + if ($this->registry instanceof UnitRegistryInterface) + return true; + + return false; + } + + /** + * Determine whether or not the converter has an active calculator. + * + * @internal + * @return bool + */ + protected function calculatorExists (): bool + { + if ($this->calculator instanceof CalculatorInterface) + return true; + + return false; + } } diff --git a/src/UnitConverter/UnitConverterInterface.php b/src/UnitConverter/UnitConverterInterface.php index 7a4970a7..878244b9 100644 --- a/src/UnitConverter/UnitConverterInterface.php +++ b/src/UnitConverter/UnitConverterInterface.php @@ -10,51 +10,55 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter; use UnitConverter\Unit\UnitInterface; /** - * The interface for any and all unit converter classes. If you want - * a custom converter, implement this interface and you are good to - * go! + * The interface for any and all unit converter classes. * * @version 1.0.0 - * @since 1.0.0 + * @since 0.0.1 * @author Jordan Brauer */ interface UnitConverterInterface { - /** - * Set the unit converters' value to be converted. This method is the first - * method to be called in the chain of conversion methods. - * - * @api - * @example $converter->convert(1)->from("in")->to("cm"); - * @param int|float|string $value The numerical value being converted. - * @param int $precision The decimal precision to be rounded to - */ - public function convert ($value, int $percision = null); + /** + * Set the unit converters' value to be converted. This method is the first + * method to be called in the chain of conversion methods. + * + * @api + * @example $converter->convert(1)->from("in")->to("cm"); + * + * @param int|float|string $value The numerical value being converted. + * @param int $precision The decimal precision to be rounded to + * @return UnitConverterInterface + */ + public function convert ($value, int $precision = null): UnitConverterInterface; - /** - * Set the unit converters' unit to be converted **from**. This method is the - * second to be called in the chain of conversion methods. - * - * @api - * @example $converter->convert(1)->from("in")->to("cm"); - * @param string $unit The unit being conerted **from**. The unit must first be registered to the UnitRegistry. - */ - public function from (string $unit); + /** + * Set the unit converters' unit to be converted **from**. This method is the + * second to be called in the chain of conversion methods. + * + * @api + * @example $converter->convert(1)->from("in")->to("cm"); + * + * @param string $unit The unit being conerted **from**. The unit must first be registered to the UnitRegistry. + * @return UnitConverterInterface + */ + public function from (string $unit): UnitConverterInterface; - /** - * Set the unit converters' unit to be converted **to**. This method is the - * third to be called in the chain of conversion methods. - * - * @api - * @example $converter->convert(1)->from("in")->to("cm"); - * @param string $unit The unit being converted **to**. The unit must first be registered to the UnitRegistry. - */ - public function to (string $unit); + /** + * Set the unit converters' unit to be converted **to**. This method is the + * third to be called in the chain of conversion methods. + * + * @api + * @example $converter->convert(1)->from("in")->to("cm"); + * + * @param string $unit The unit being converted **to**. The unit must first be registered to the UnitRegistry. + * @return int|float|string + */ + public function to (string $unit); } diff --git a/tests/integration/UnitConverter/Unit/Energy/EnergyUnits.spec.php b/tests/integration/UnitConverter/Unit/Energy/EnergyUnits.spec.php index 9eb80568..0e5ebbee 100644 --- a/tests/integration/UnitConverter/Unit/Energy/EnergyUnits.spec.php +++ b/tests/integration/UnitConverter/Unit/Energy/EnergyUnits.spec.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Tests\Integration\Unit\Energy; @@ -23,40 +23,38 @@ /** * Test the default volume units for conversion accuracy. - * - * @author Jordan Brauer */ class EnergyUnitsSpec extends TestCase { - protected function setUp () - { - $this->converter = new UnitConverter( - new UnitRegistry(array( - new Joule, - new Calorie, - )), - new SimpleCalculator - ); - } - - protected function tearDown () - { - unset($this->converter); - } - - /** - * @test - * @coversNothing - */ - public function assert1CalorieEquals4184Joules () - { - $expected = 4184; - $actual = $this->converter - ->convert(1) - ->from("cal") - ->to("J") - ; - - $this->assertEquals($expected, $actual); - } + protected function setUp () + { + $this->converter = new UnitConverter( + new UnitRegistry(array( + new Joule, + new Calorie, + )), + new SimpleCalculator + ); + } + + protected function tearDown () + { + unset($this->converter); + } + + /** + * @test + * @coversNothing + */ + public function assert1CalorieEquals4184Joules () + { + $expected = 4184; + $actual = $this->converter + ->convert(1) + ->from("cal") + ->to("J") + ; + + $this->assertEquals($expected, $actual); + } } diff --git a/tests/integration/UnitConverter/Unit/Pressure/PressureUnits.spec.php b/tests/integration/UnitConverter/Unit/Pressure/PressureUnits.spec.php index d6985b81..17fcca00 100644 --- a/tests/integration/UnitConverter/Unit/Pressure/PressureUnits.spec.php +++ b/tests/integration/UnitConverter/Unit/Pressure/PressureUnits.spec.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Tests\Integration\Unit\Pressure; @@ -24,43 +24,41 @@ /** * Test the default pressure units for conversion accuracy. - * - * @author Jordan Brauer */ class PressureUnitsSpec extends TestCase { - protected function setUp () - { - $this->converter = new UnitConverter( - new UnitRegistry(array( - new Pascal, - new Kilopascal, - new PSI, - )), - new SimpleCalculator - ); - } - - protected function tearDown () - { - unset($this->converter); - } - - /** - * @test - * @coversNothing - */ - public function assertZeroCelsiusEqualsTwoHundredSeventyThreeDecimalFifteen () - { - $expected = 6894.76; - $actual = $this->converter - ->convert(1) - ->from("psi") - ->to("pa") - ; - - $this->assertEquals($expected, $actual); - } + protected function setUp () + { + $this->converter = new UnitConverter( + new UnitRegistry(array( + new Pascal, + new Kilopascal, + new PSI, + )), + new SimpleCalculator + ); + } + + protected function tearDown () + { + unset($this->converter); + } + + /** + * @test + * @coversNothing + */ + public function assertZeroCelsiusEqualsTwoHundredSeventyThreeDecimalFifteen () + { + $expected = 6894.76; + $actual = $this->converter + ->convert(1) + ->from("psi") + ->to("pa") + ; + + $this->assertEquals($expected, $actual); + } /** * @test @@ -73,7 +71,7 @@ public function assert1kpaEquals1000pa() ->convert(1) ->from("kpa") ->to("pa") - ; + ; $this->assertEquals($expected, $actual); } @@ -89,7 +87,7 @@ public function assert1000paEquals1kpa() ->convert(1000) ->from("pa") ->to("kpa") - ; + ; $this->assertEquals($expected, $actual); } @@ -104,7 +102,7 @@ public function assert1mpaEquals1000000pa() ->convert(1) ->from("mpa") ->to("pa") - ; + ; $this->assertEquals($expected, $actual); } @@ -119,7 +117,7 @@ public function assert1mpaEquals1000kpa() ->convert(1) ->from("mpa") ->to("kpa") - ; + ; $this->assertEquals($expected, $actual); } diff --git a/tests/integration/UnitConverter/Unit/Temperature/TemperatureUnits.spec.php b/tests/integration/UnitConverter/Unit/Temperature/TemperatureUnits.spec.php index 19250bce..b26c5fce 100644 --- a/tests/integration/UnitConverter/Unit/Temperature/TemperatureUnits.spec.php +++ b/tests/integration/UnitConverter/Unit/Temperature/TemperatureUnits.spec.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Tests\Integration\Unit\Temperature; @@ -24,89 +24,87 @@ /** * Test the default temperature units for conversion accuracy. - * - * @author Jordan Brauer */ class TemperatureUnitsSpec extends TestCase { - protected function setUp () - { - $this->converter = new UnitConverter( - new UnitRegistry(array( - new Celsius, - new Fahrenheit, - new Kelvin, - )), - new SimpleCalculator - ); - } + protected function setUp () + { + $this->converter = new UnitConverter( + new UnitRegistry(array( + new Celsius, + new Fahrenheit, + new Kelvin, + )), + new SimpleCalculator + ); + } - protected function tearDown () - { - unset($this->converter); - } + protected function tearDown () + { + unset($this->converter); + } - /** - * @test - * @coversNothing - */ - public function assertZeroCelsiusEqualsTwoHundredSeventyThreeDecimalFifteen () - { - $expected = 273.15; - $actual = $this->converter - ->convert(0) - ->from("c") - ->to("k") - ; + /** + * @test + * @coversNothing + */ + public function assertZeroCelsiusEqualsTwoHundredSeventyThreeDecimalFifteen () + { + $expected = 273.15; + $actual = $this->converter + ->convert(0) + ->from("c") + ->to("k") + ; - $this->assertEquals($expected, $actual); - } + $this->assertEquals($expected, $actual); + } - /** - * @test - * @coversNothing - */ - public function assertZeroFahrenheitEqualsTwoHundredFiftyFiveDecimalThreeHundredSeventyTwo () - { - $expected = 255.37; - $actual = $this->converter - ->convert(0) - ->from("f") - ->to("k") - ; + /** + * @test + * @coversNothing + */ + public function assertZeroFahrenheitEqualsTwoHundredFiftyFiveDecimalThreeHundredSeventyTwo () + { + $expected = 255.37; + $actual = $this->converter + ->convert(0) + ->from("f") + ->to("k") + ; - $this->assertEquals($expected, $actual); - } + $this->assertEquals($expected, $actual); + } - /** - * @test - * @coversNothing - */ - public function assertZeroCelsiusEqualsThirtyTwoFahrenheit () - { - $expected = 32; - $actual = $this->converter - ->convert(0) - ->from("c") - ->to("f") - ; + /** + * @test + * @coversNothing + */ + public function assertZeroCelsiusEqualsThirtyTwoFahrenheit () + { + $expected = 32; + $actual = $this->converter + ->convert(0) + ->from("c") + ->to("f") + ; - $this->assertEquals($expected, $actual); - } + $this->assertEquals($expected, $actual); + } - /** - * @test - * @coversNothing - */ - public function assertZeroFahrenheitEqualsNegativeSeventeenDecimalSevenThousandSevenHundredSeventyEightCelsius () - { - $expected = -17.7778; - $actual = $this->converter - ->convert(0, 4) - ->from("f") - ->to("c") - ; + /** + * @test + * @coversNothing + */ + public function assertZeroFahrenheitEqualsNegativeSeventeenDecimalSevenThousandSevenHundredSeventyEightCelsius () + { + $expected = -17.7778; + $actual = $this->converter + ->convert(0, 4) + ->from("f") + ->to("c") + ; - $this->assertEquals($expected, $actual); - } + $this->assertEquals($expected, $actual); + } } diff --git a/tests/integration/UnitConverter/Unit/Volume/VolumeUnits.spec.php b/tests/integration/UnitConverter/Unit/Volume/VolumeUnits.spec.php index ac66df32..7fc8a4ad 100644 --- a/tests/integration/UnitConverter/Unit/Volume/VolumeUnits.spec.php +++ b/tests/integration/UnitConverter/Unit/Volume/VolumeUnits.spec.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Tests\Integration\Unit\Volume; @@ -25,42 +25,40 @@ /** * Test the default volume units for conversion accuracy. - * - * @author Jordan Brauer */ class VolumeUnitsSpec extends TestCase { - protected function setUp () - { - $this->converter = new UnitConverter( - new UnitRegistry(array( - new Litre, - new Mililitre, - new Gallon, - new Pint, - )), - new SimpleCalculator - ); - } + protected function setUp () + { + $this->converter = new UnitConverter( + new UnitRegistry(array( + new Litre, + new Mililitre, + new Gallon, + new Pint, + )), + new SimpleCalculator + ); + } - protected function tearDown () - { - unset($this->converter); - } + protected function tearDown () + { + unset($this->converter); + } - /** - * @test - * @coversNothing - */ - public function assert () - { - $expected = 4.73176; - $actual = $this->converter - ->convert(10, 5) - ->from("pt") - ->to("l") - ; + /** + * @test + * @coversNothing + */ + public function assert () + { + $expected = 4.73176; + $actual = $this->converter + ->convert(10, 5) + ->from("pt") + ->to("l") + ; - $this->assertEquals($expected, $actual); - } + $this->assertEquals($expected, $actual); + } } diff --git a/tests/unit/UnitConverter/Calculator/BinaryCalculator.spec.php b/tests/unit/UnitConverter/Calculator/BinaryCalculator.spec.php index 278dca66..0c2a1027 100644 --- a/tests/unit/UnitConverter/Calculator/BinaryCalculator.spec.php +++ b/tests/unit/UnitConverter/Calculator/BinaryCalculator.spec.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Tests\Unit\Calculator; @@ -23,91 +23,91 @@ */ class BinaryCalculatorSpec extends TestCase { - protected function setUp() - { - $this->calculator = new BinaryCalculator; - } - - protected function tearDown() - { - unset($this->calculator); - } - - /** - * @test - * @covers ::add - */ - public function assertAddingTwoNumbersWorksAsExpected () - { - $expected = 5; - $actual = $this->calculator->add("2.5", "2.5"); - - $this->assertEquals($expected, $actual); - $this->assertInternalType("string", $actual); - } - - /** - * @test - * @covers ::sub - */ - public function assertSubtractingTwoNumbersWorksAsExpected () - { - $expected = 2.5; - $actual = $this->calculator->sub("5", "2.5"); - - $this->assertEquals($expected, $actual); - $this->assertInternalType("string", $actual); - } - - /** - * @test - * @covers ::mul - */ - public function assertMultiplyMethodProperlyMultipliesTwoNumbers () - { - $expected = 4; - $actual = $this->calculator->mul("2", "2"); - - $this->assertEquals($expected, $actual); - $this->assertInternalType("string", $actual); - } - - /** - * @test - * @covers ::div - */ - public function assertDivideMethodProperlyDividesTwoNumbers () - { - $expected = 2; - $actual = $this->calculator->div("4", "2"); - - $this->assertEquals($expected, $actual); - $this->assertInternalType("string", $actual); - } - - /** - * @test - * @covers ::mod - */ - public function assertModulusMethodProperlyReturnsTheRemainderOfDivision () - { - $expected = 1; - $actual = $this->calculator->mod("5", "2"); - - $this->assertEquals($expected, $actual); - $this->assertInternalType("string", $actual); - } - - /** - * @test - * @covers ::pow - */ - public function assertPowerMethodRaisesBaseNumberToPowerExponent () - { - $expected = 100; - $actual = $this->calculator->pow("10", "2"); - - $this->assertEquals($expected, $actual); - $this->assertInternalType("string", $actual); - } + protected function setUp() + { + $this->calculator = new BinaryCalculator; + } + + protected function tearDown() + { + unset($this->calculator); + } + + /** + * @test + * @covers ::add + */ + public function assertAddingTwoNumbersWorksAsExpected () + { + $expected = 5; + $actual = $this->calculator->add("2.5", "2.5"); + + $this->assertEquals($expected, $actual); + $this->assertInternalType("string", $actual); + } + + /** + * @test + * @covers ::sub + */ + public function assertSubtractingTwoNumbersWorksAsExpected () + { + $expected = 2.5; + $actual = $this->calculator->sub("5", "2.5"); + + $this->assertEquals($expected, $actual); + $this->assertInternalType("string", $actual); + } + + /** + * @test + * @covers ::mul + */ + public function assertMultiplyMethodProperlyMultipliesTwoNumbers () + { + $expected = 4; + $actual = $this->calculator->mul("2", "2"); + + $this->assertEquals($expected, $actual); + $this->assertInternalType("string", $actual); + } + + /** + * @test + * @covers ::div + */ + public function assertDivideMethodProperlyDividesTwoNumbers () + { + $expected = 2; + $actual = $this->calculator->div("4", "2"); + + $this->assertEquals($expected, $actual); + $this->assertInternalType("string", $actual); + } + + /** + * @test + * @covers ::mod + */ + public function assertModulusMethodProperlyReturnsTheRemainderOfDivision () + { + $expected = 1; + $actual = $this->calculator->mod("5", "2"); + + $this->assertEquals($expected, $actual); + $this->assertInternalType("string", $actual); + } + + /** + * @test + * @covers ::pow + */ + public function assertPowerMethodRaisesBaseNumberToPowerExponent () + { + $expected = 100; + $actual = $this->calculator->pow("10", "2"); + + $this->assertEquals($expected, $actual); + $this->assertInternalType("string", $actual); + } } diff --git a/tests/unit/UnitConverter/Calculator/SimpleCalculator.spec.php b/tests/unit/UnitConverter/Calculator/SimpleCalculator.spec.php index 94b9bf01..52695b9f 100644 --- a/tests/unit/UnitConverter/Calculator/SimpleCalculator.spec.php +++ b/tests/unit/UnitConverter/Calculator/SimpleCalculator.spec.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Tests\Unit\Calculator; @@ -23,91 +23,91 @@ */ class SimpleCalculatorSpec extends TestCase { - protected function setUp() - { - $this->calculator = new SimpleCalculator; - } - - protected function tearDown() - { - unset($this->calculator); - } - - /** - * @test - * @covers ::add - */ - public function assertAddingTwoNumbersWorksAsExpected () - { - $expected = 5; - $actual = $this->calculator->add("2.5", "2.5"); - - $this->assertEquals($expected, $actual); - $this->assertInternalType("float", $actual); - } - - /** - * @test - * @covers ::sub - */ - public function assertSubtractingTwoNumbersWorksAsExpected () - { - $expected = 2.5; - $actual = $this->calculator->sub("5", "2.5"); - - $this->assertEquals($expected, $actual); - $this->assertInternalType("float", $actual); - } - - /** - * @test - * @covers ::mul - */ - public function assertMultiplyMethodProperlyMultipliesTwoNumbers () - { - $expected = 4; - $actual = $this->calculator->mul("2", "2"); - - $this->assertEquals($expected, $actual); - $this->assertInternalType("int", $actual); - } - - /** - * @test - * @covers ::div - */ - public function assertDivideMethodProperlyDividesTwoNumbers () - { - $expected = 2; - $actual = $this->calculator->div("4", "2"); - - $this->assertEquals($expected, $actual); - $this->assertInternalType("int", $actual); - } - - /** - * @test - * @covers ::mod - */ - public function assertModulusMethodProperlyReturnsTheRemainderOfDivision () - { - $expected = 1; - $actual = $this->calculator->mod("5", "2"); - - $this->assertEquals($expected, $actual); - $this->assertInternalType("int", $actual); - } - - /** - * @test - * @covers ::pow - */ - public function assertPowerMethodRaisesBaseNumberToPowerExponent () - { - $expected = 100; - $actual = $this->calculator->pow("10", "2"); - - $this->assertEquals($expected, $actual); - $this->assertInternalType("int", $actual); - } + protected function setUp() + { + $this->calculator = new SimpleCalculator; + } + + protected function tearDown() + { + unset($this->calculator); + } + + /** + * @test + * @covers ::add + */ + public function assertAddingTwoNumbersWorksAsExpected () + { + $expected = 5; + $actual = $this->calculator->add("2.5", "2.5"); + + $this->assertEquals($expected, $actual); + $this->assertInternalType("float", $actual); + } + + /** + * @test + * @covers ::sub + */ + public function assertSubtractingTwoNumbersWorksAsExpected () + { + $expected = 2.5; + $actual = $this->calculator->sub("5", "2.5"); + + $this->assertEquals($expected, $actual); + $this->assertInternalType("float", $actual); + } + + /** + * @test + * @covers ::mul + */ + public function assertMultiplyMethodProperlyMultipliesTwoNumbers () + { + $expected = 4; + $actual = $this->calculator->mul("2", "2"); + + $this->assertEquals($expected, $actual); + $this->assertInternalType("int", $actual); + } + + /** + * @test + * @covers ::div + */ + public function assertDivideMethodProperlyDividesTwoNumbers () + { + $expected = 2; + $actual = $this->calculator->div("4", "2"); + + $this->assertEquals($expected, $actual); + $this->assertInternalType("int", $actual); + } + + /** + * @test + * @covers ::mod + */ + public function assertModulusMethodProperlyReturnsTheRemainderOfDivision () + { + $expected = 1; + $actual = $this->calculator->mod("5", "2"); + + $this->assertEquals($expected, $actual); + $this->assertInternalType("int", $actual); + } + + /** + * @test + * @covers ::pow + */ + public function assertPowerMethodRaisesBaseNumberToPowerExponent () + { + $expected = 100; + $actual = $this->calculator->pow("10", "2"); + + $this->assertEquals($expected, $actual); + $this->assertInternalType("int", $actual); + } } diff --git a/tests/unit/UnitConverter/Registry/UnitRegistry.spec.php b/tests/unit/UnitConverter/Registry/UnitRegistry.spec.php index df376b5d..b995e9d6 100644 --- a/tests/unit/UnitConverter/Registry/UnitRegistry.spec.php +++ b/tests/unit/UnitConverter/Registry/UnitRegistry.spec.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Tests\Unit\Registry; @@ -18,243 +18,240 @@ use UnitConverter\Registry\UnitRegistry; use UnitConverter\Unit\UnitInterface; use UnitConverter\Unit\AbstractUnit; -use UnitConverter\Unit\Length\{ - Centimeter, - Inch, - Meter, - Milimeter -}; +use UnitConverter\Unit\Length\Centimeter; +use UnitConverter\Unit\Length\Inch; +use UnitConverter\Unit\Length\Meter; +use UnitConverter\Unit\Length\Milimeter; /** * @coversDefaultClass UnitConverter\UnitRegistry - * @author Jordan Brauer */ class UnitRegistrySpec extends TestCase { - protected function setUp () - { - $this->registry = new UnitRegistry(array( - new Centimeter, - new Inch, - )); - } + protected function setUp () + { + $this->registry = new UnitRegistry(array( + new Centimeter, + new Inch, + )); + } - protected function tearDown () - { - unset($this->registry); - } + protected function tearDown () + { + unset($this->registry); + } - /** - * @test - * @covers ::isMeasurementRegistered - */ - public function assertMeasurementIsRegistered () - { - $this->assertTrue($this->registry->isMeasurementRegistered("length")); - $this->assertFalse($this->registry->isMeasurementRegistered("saiyanPower")); - } + /** + * @test + * @covers ::isMeasurementRegistered + */ + public function assertMeasurementIsRegistered () + { + $this->assertTrue($this->registry->isMeasurementRegistered("length")); + $this->assertFalse($this->registry->isMeasurementRegistered("saiyanPower")); + } - /** - * @test - * @covers ::isUnitRegistered - */ - public function assertUnitIsRegistered () - { - $this->assertTrue($this->registry->isUnitRegistered("cm")); - $this->assertFalse($this->registry->isUnitRegistered("yd")); - } + /** + * @test + * @covers ::isUnitRegistered + */ + public function assertUnitIsRegistered () + { + $this->assertTrue($this->registry->isUnitRegistered("cm")); + $this->assertFalse($this->registry->isUnitRegistered("yd")); + } - /** - * @test - * @covers ::loadUnit - */ - public function assertUnitObjectIsLoaded () - { - $actual = $this->registry->loadUnit("cm"); - $expected = UnitInterface::class; + /** + * @test + * @covers ::loadUnit + */ + public function assertUnitObjectIsLoaded () + { + $actual = $this->registry->loadUnit("cm"); + $expected = UnitInterface::class; - $this->assertInstanceOf($expected, $actual); - } + $this->assertInstanceOf($expected, $actual); + } - /** - * @test - * @coversNothing - */ - public function assertOutOfBoundsExceptionIsThrownForUnregisteredUnits () - { - $this->expectException("UnitConverter\\Exception\\UnknownUnitOfMeasureException"); - $this->registry->loadUnit("yd"); - } + /** + * @test + * @coversNothing + */ + public function assertOutOfBoundsExceptionIsThrownForUnregisteredUnits () + { + $this->expectException("UnitConverter\\Exception\\UnknownUnitOfMeasureException"); + $this->registry->loadUnit("yd"); + } - /** - * @test - * @covers ::listMeasurements - */ - public function assertListMeasurementsMethodReturnsArray () - { - $actual = $this->registry->listMeasurements(); - $expected = array( - "length", - "area", - "volume", - "mass", - "speed", - "plane_angle", - "temperature", - "pressure", - "time", - "energy", - ); + /** + * @test + * @covers ::listMeasurements + */ + public function assertListMeasurementsMethodReturnsArray () + { + $actual = $this->registry->listMeasurements(); + $expected = array( + "length", + "area", + "volume", + "mass", + "speed", + "plane_angle", + "temperature", + "pressure", + "time", + "energy", + ); - $this->assertEquals($expected, $actual); - $this->assertInternalType("array", $actual); - $this->assertTrue((count($actual) > 0)); - } + $this->assertEquals($expected, $actual); + $this->assertInternalType("array", $actual); + $this->assertTrue((count($actual) > 0)); + } - /** - * @test - * @covers ::listUnits - */ - public function assertListUnitsMethodReturnsArray () - { - $actual = $this->registry->listUnits(); - $expected = array( - "cm", - "in", - ); + /** + * @test + * @covers ::listUnits + */ + public function assertListUnitsMethodReturnsArray () + { + $actual = $this->registry->listUnits(); + $expected = array( + "cm", + "in", + ); - $this->assertEquals($expected, $actual); - $this->assertInternalType("array", $actual); - $this->assertTrue((count($actual) > 0)); - } + $this->assertEquals($expected, $actual); + $this->assertInternalType("array", $actual); + $this->assertTrue((count($actual) > 0)); + } - /** - * @test - * @covers ::registerMeasurement - * @covers ::registerMeasurements - * @uses ::isMeasurementRegistered - */ - public function assertRegisterMeasurementMethodsAddItemsToUnitRegistry () - { - $this->assertFalse($this->registry->isMeasurementRegistered("data")); - $this->assertFalse($this->registry->isMeasurementRegistered("saiyanPower")); - $this->assertFalse($this->registry->isMeasurementRegistered("funniness")); + /** + * @test + * @covers ::registerMeasurement + * @covers ::registerMeasurements + * @uses ::isMeasurementRegistered + */ + public function assertRegisterMeasurementMethodsAddItemsToUnitRegistry () + { + $this->assertFalse($this->registry->isMeasurementRegistered("data")); + $this->assertFalse($this->registry->isMeasurementRegistered("saiyanPower")); + $this->assertFalse($this->registry->isMeasurementRegistered("funniness")); - $this->registry->registerMeasurement("data"); - $this->registry->registerMeasurements(["saiyanPower", "funniness"]); + $this->registry->registerMeasurement("data"); + $this->registry->registerMeasurements(["saiyanPower", "funniness"]); - $this->assertTrue($this->registry->isMeasurementRegistered("data")); - $this->assertTrue($this->registry->isMeasurementRegistered("saiyanPower")); - $this->assertTrue($this->registry->isMeasurementRegistered("funniness")); - } + $this->assertTrue($this->registry->isMeasurementRegistered("data")); + $this->assertTrue($this->registry->isMeasurementRegistered("saiyanPower")); + $this->assertTrue($this->registry->isMeasurementRegistered("funniness")); + } - /** - * @test - * @covers ::registerUnit - * @covers ::registerUnits - * @uses ::isUnitRegistered - */ - public function assertRegisterUnitMethodsAddItemsToUnitRegistry () - { - $this->assertFalse($this->registry->isUnitRegistered("sP")); - $this->assertFalse($this->registry->isUnitRegistered("m")); - $this->assertFalse($this->registry->isUnitRegistered("mm")); + /** + * @test + * @covers ::registerUnit + * @covers ::registerUnits + * @uses ::isUnitRegistered + */ + public function assertRegisterUnitMethodsAddItemsToUnitRegistry () + { + $this->assertFalse($this->registry->isUnitRegistered("sP")); + $this->assertFalse($this->registry->isUnitRegistered("m")); + $this->assertFalse($this->registry->isUnitRegistered("mm")); - $this->registry->registerUnit(new class extends AbstractUnit { - protected function configure () : void - { - $this - ->setName("saiyanPower") - ->setSymbol("sP") - ->setUnitOf("energy") - ->setBase(self::class) - ->setUnits(9001) - ; - } - }); - $this->registry->registerUnits([new Meter, new Milimeter]); + $this->registry->registerUnit(new class extends AbstractUnit { + protected function configure () : void + { + $this + ->setName("saiyanPower") + ->setSymbol("sP") + ->setUnitOf("energy") + ->setBase(self::class) + ->setUnits(9001) + ; + } + }); + $this->registry->registerUnits([new Meter, new Milimeter]); - $this->assertTrue($this->registry->isUnitRegistered("sP")); - $this->assertTrue($this->registry->isUnitRegistered("m")); - $this->assertTrue($this->registry->isUnitRegistered("mm")); - } + $this->assertTrue($this->registry->isUnitRegistered("sP")); + $this->assertTrue($this->registry->isUnitRegistered("m")); + $this->assertTrue($this->registry->isUnitRegistered("mm")); + } - /** - * @test - * @coversNothing - */ - public function assertRegisteringUnitsUnderUnknownMeasurementsThrowsOutOfBoundsException () - { - $this->expectException("UnitConverter\\Exception\\UnknownMeasurementTypeException"); - $this->registry->registerUnit(new class extends AbstractUnit { - protected function configure () : void - { - $this - ->setName("testtt") - ->setSymbol("Tst") - ->setUnitOf("NO EXIST LOL") - ->setBase(self::class) - ->setUnits(1) - ; - } - }); - } + /** + * @test + * @coversNothing + */ + public function assertRegisteringUnitsUnderUnknownMeasurementsThrowsOutOfBoundsException () + { + $this->expectException("UnitConverter\\Exception\\UnknownMeasurementTypeException"); + $this->registry->registerUnit(new class extends AbstractUnit { + protected function configure () : void + { + $this + ->setName("testtt") + ->setSymbol("Tst") + ->setUnitOf("NO EXIST LOL") + ->setBase(self::class) + ->setUnits(1) + ; + } + }); + } - /** - * @test - * @covers ::unregisterMeasurement - * @covers ::unregisterMeasurements - * @uses ::isMeasurementRegistered - */ - public function assertUnregisterMeasurementMethodsRemoveItemsFromUnitRegistry () - { - $this->assertTrue($this->registry->isMeasurementRegistered("length")); - $this->assertTrue($this->registry->isMeasurementRegistered("mass")); - $this->assertTrue($this->registry->isMeasurementRegistered("volume")); + /** + * @test + * @covers ::unregisterMeasurement + * @covers ::unregisterMeasurements + * @uses ::isMeasurementRegistered + */ + public function assertUnregisterMeasurementMethodsRemoveItemsFromUnitRegistry () + { + $this->assertTrue($this->registry->isMeasurementRegistered("length")); + $this->assertTrue($this->registry->isMeasurementRegistered("mass")); + $this->assertTrue($this->registry->isMeasurementRegistered("volume")); - $this->registry->unregisterMeasurement("length"); - $this->registry->unregisterMeasurements(array("mass", "volume")); + $this->registry->unregisterMeasurement("length"); + $this->registry->unregisterMeasurements(array("mass", "volume")); - $this->assertFalse($this->registry->isMeasurementRegistered("length")); - $this->assertFalse($this->registry->isMeasurementRegistered("mass")); - $this->assertFalse($this->registry->isMeasurementRegistered("volume")); - } + $this->assertFalse($this->registry->isMeasurementRegistered("length")); + $this->assertFalse($this->registry->isMeasurementRegistered("mass")); + $this->assertFalse($this->registry->isMeasurementRegistered("volume")); + } - /** - * @test - * @coversNothing - */ - public function assertUnregisteringUnknownMeasurementsThrowsOutOfBoundsException () - { - $this->expectException("UnitConverter\\Exception\\UnknownMeasurementTypeException"); - $this->registry->unregisterMeasurement("NOT REAL"); - } + /** + * @test + * @coversNothing + */ + public function assertUnregisteringUnknownMeasurementsThrowsOutOfBoundsException () + { + $this->expectException("UnitConverter\\Exception\\UnknownMeasurementTypeException"); + $this->registry->unregisterMeasurement("NOT REAL"); + } - /** - * @test - * @covers ::unregisterUnit - * @covers ::unregisterUnits - * @uses ::isUnitRegistered - */ - public function assertUnregisterUnitMethodsRemoveItemsFromUnitRegistry () - { - $this->assertTrue($this->registry->isUnitRegistered("cm")); - $this->assertTrue($this->registry->isUnitRegistered("in")); + /** + * @test + * @covers ::unregisterUnit + * @covers ::unregisterUnits + * @uses ::isUnitRegistered + */ + public function assertUnregisterUnitMethodsRemoveItemsFromUnitRegistry () + { + $this->assertTrue($this->registry->isUnitRegistered("cm")); + $this->assertTrue($this->registry->isUnitRegistered("in")); - $this->registry->unregisterUnit("cm"); - $this->registry->unregisterUnits(array("in")); + $this->registry->unregisterUnit("cm"); + $this->registry->unregisterUnits(array("in")); - $this->assertFalse($this->registry->isUnitRegistered("cm")); - $this->assertFalse($this->registry->isUnitRegistered("in")); - } + $this->assertFalse($this->registry->isUnitRegistered("cm")); + $this->assertFalse($this->registry->isUnitRegistered("in")); + } - /** - * @test - * @coversNothing - */ - public function assertUnregisteringUnknownUnitsThrowsOutOfBoundsException () - { - $this->expectException("UnitConverter\\Exception\\UnknownUnitOfMeasureException"); - $this->registry->unregisterUnit("nOtREal"); - } + /** + * @test + * @coversNothing + */ + public function assertUnregisteringUnknownUnitsThrowsOutOfBoundsException () + { + $this->expectException("UnitConverter\\Exception\\UnknownUnitOfMeasureException"); + $this->registry->unregisterUnit("nOtREal"); + } } diff --git a/tests/unit/UnitConverter/Unit/AbstractUnit.spec.php b/tests/unit/UnitConverter/Unit/AbstractUnit.spec.php index 6f4b885f..ecf44e38 100644 --- a/tests/unit/UnitConverter/Unit/AbstractUnit.spec.php +++ b/tests/unit/UnitConverter/Unit/AbstractUnit.spec.php @@ -10,109 +10,106 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Tests\Unit\Unit; use PHPUnit\Framework\TestCase; use UnitConverter\Measure; use UnitConverter\Unit\AbstractUnit; -use UnitConverter\Unit\Length\{ - Centimeter, - Inch, - Meter -}; +use UnitConverter\Unit\Length\Centimeter; +use UnitConverter\Unit\Length\Inch; +use UnitConverter\Unit\Length\Meter; /** * @coversDefaultClass UnitConverter\UnitConverter - * @author Jordan Brauer */ class AbstractUnitSpec extends TestCase { - protected function setUp () - { - $this->unit = new class extends AbstractUnit + protected function setUp () { - protected $name = "saiyan power"; - protected $symbol = "sP"; - protected $unitOf = Measure::LENGTH; - protected $base = Meter::class; - protected $units = 9001; - }; - } - - protected function tearDown () - { - unset($this->unit); - } - - /** - * @test - * @covers ::setName - * @covers ::getName - */ - public function assertGetNameSetNameMethodsCanReadAndWriteToUnitName () - { - $this->unit->setName("test set"); - $actual = $this->unit->getName(); - - $this->assertEquals("test set", $actual); - $this->assertInternalType("string", $actual); - } - - /** - * @test - * @covers ::setSymbol - * @covers ::getSymbol - */ - public function assertGetSymbolSetSymbolMethodsCanReadAndWriteToUnitSymbol () - { - $this->unit->setSymbol("tS"); - $actual = $this->unit->getSymbol(); - - $this->assertEquals("tS", $actual); - $this->assertInternalType("string", $actual); - } - - /** - * @test - * @covers ::setUnitOf - * @covers ::getUnitOf - */ - public function assertGetUnitOfSetUnitOfMethodsCanReadAndWriteToUnitUnitOf () - { - $this->unit->setUnitOf(Measure::ENERGY); - $actual = $this->unit->getUnitOf(); - - $this->assertEquals(Measure::ENERGY, $actual); - $this->assertInternalType("string", $actual); - } - - /** - * @test - * @covers ::setBase - * @covers ::getBase - */ - public function assertGetBaseSetBaseMethodsCanReadAndWriteToUnitBase () - { - $this->unit->setBase(new Inch); - $actual = $this->unit->getBase(); - - $this->assertInstanceOf(Inch::class, $actual); - $this->assertInternalType("object", $actual); - } - - /** - * @test - * @covers ::setUnits - * @covers ::getUnits - */ - public function assertGetUnitsSetUnitsMethodsCanReadAndWriteToUnitUnits () - { - $this->unit->setUnits(69); - $actual = $this->unit->getUnits(); - - $this->assertEquals(69, $actual); - $this->assertInternalType("float", $actual); - } + $this->unit = new class extends AbstractUnit + { + protected $name = "saiyan power"; + protected $symbol = "sP"; + protected $unitOf = Measure::LENGTH; + protected $base = Meter::class; + protected $units = 9001; + }; + } + + protected function tearDown () + { + unset($this->unit); + } + + /** + * @test + * @covers ::setName + * @covers ::getName + */ + public function assertGetNameSetNameMethodsCanReadAndWriteToUnitName () + { + $this->unit->setName("test set"); + $actual = $this->unit->getName(); + + $this->assertEquals("test set", $actual); + $this->assertInternalType("string", $actual); + } + + /** + * @test + * @covers ::setSymbol + * @covers ::getSymbol + */ + public function assertGetSymbolSetSymbolMethodsCanReadAndWriteToUnitSymbol () + { + $this->unit->setSymbol("tS"); + $actual = $this->unit->getSymbol(); + + $this->assertEquals("tS", $actual); + $this->assertInternalType("string", $actual); + } + + /** + * @test + * @covers ::setUnitOf + * @covers ::getUnitOf + */ + public function assertGetUnitOfSetUnitOfMethodsCanReadAndWriteToUnitUnitOf () + { + $this->unit->setUnitOf(Measure::ENERGY); + $actual = $this->unit->getUnitOf(); + + $this->assertEquals(Measure::ENERGY, $actual); + $this->assertInternalType("string", $actual); + } + + /** + * @test + * @covers ::setBase + * @covers ::getBase + */ + public function assertGetBaseSetBaseMethodsCanReadAndWriteToUnitBase () + { + $this->unit->setBase(new Inch); + $actual = $this->unit->getBase(); + + $this->assertInstanceOf(Inch::class, $actual); + $this->assertInternalType("object", $actual); + } + + /** + * @test + * @covers ::setUnits + * @covers ::getUnits + */ + public function assertGetUnitsSetUnitsMethodsCanReadAndWriteToUnitUnits () + { + $this->unit->setUnits(69); + $actual = $this->unit->getUnits(); + + $this->assertEquals(69, $actual); + $this->assertInternalType("float", $actual); + } } diff --git a/tests/unit/UnitConverter/UnitConverter.spec.php b/tests/unit/UnitConverter/UnitConverter.spec.php index ef374fbd..19a51905 100644 --- a/tests/unit/UnitConverter/UnitConverter.spec.php +++ b/tests/unit/UnitConverter/UnitConverter.spec.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -declare(strict_types = 1); +declare (strict_types = 1); namespace UnitConverter\Tests\Unit; @@ -18,64 +18,61 @@ use UnitConverter\UnitConverter; use UnitConverter\Calculator\SimpleCalculator; use UnitConverter\Registry\UnitRegistry; -use UnitConverter\Unit\Length\{ - Centimeter, - Inch -}; +use UnitConverter\Unit\Length\Centimeter; +use UnitConverter\Unit\Length\Inch; /** * @coversDefaultClass UnitConverter\UnitConverter - * @author Jordan Brauer */ class UnitConverterSpec extends TestCase { - protected function setUp () - { - $this->converter = new UnitConverter( - new UnitRegistry(array( - new Centimeter, - new Inch, - )), - new SimpleCalculator - ); - } + protected function setUp () + { + $this->converter = new UnitConverter( + new UnitRegistry(array( + new Centimeter, + new Inch, + )), + new SimpleCalculator + ); + } - protected function tearDown () - { - unset($this->converter); - } + protected function tearDown () + { + unset($this->converter); + } - /** - * @test - * @covers ::convert - * @covers ::from - * @covers ::to - * @covers ::calculate - */ - public function assertCalculateMethodReturnsCorrectCalculation () - { - $expected = 2.54; # = (1 * 0.0254) / 0.01 - $actual = $this->converter - ->convert(1) - ->from("in") - ->to("cm") - ; + /** + * @test + * @covers ::convert + * @covers ::from + * @covers ::to + * @covers ::calculate + */ + public function assertCalculateMethodReturnsCorrectCalculation () + { + $expected = 2.54; # = (1 * 0.0254) / 0.01 + $actual = $this->converter + ->convert(1) + ->from("in") + ->to("cm") + ; - $this->assertEquals($expected, $actual); - $this->assertInternalType("float", $actual); - } + $this->assertEquals($expected, $actual); + $this->assertInternalType("float", $actual); + } - /** - * @test - * @coversNothing - */ - public function assertConversionThrowsErrorExceptionAtUnknownUnits () - { - $this->expectException("UnitConverter\\Exception\\UnknownUnitOfMeasureException"); - $this->converter - ->convert(1) - ->from("yd") # any unregistered unit - ->to("in") - ; - } + /** + * @test + * @coversNothing + */ + public function assertConversionThrowsErrorExceptionAtUnknownUnits () + { + $this->expectException("UnitConverter\\Exception\\UnknownUnitOfMeasureException"); + $this->converter + ->convert(1) + ->from("yd") # any unregistered unit + ->to("in") + ; + } }