From b4934525cd424165a6c8f5e08e9478d998637fae Mon Sep 17 00:00:00 2001 From: andreboerema <1569403+andrewboerema@users.noreply.github.com> Date: Wed, 11 Oct 2017 12:31:13 -0500 Subject: [PATCH 1/3] Properly casing unit symbols --- src/UnitConverter/Unit/Energy/Joule.php | 2 +- src/UnitConverter/Unit/Energy/WattHour.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/UnitConverter/Unit/Energy/Joule.php b/src/UnitConverter/Unit/Energy/Joule.php index 2d42d9f3..d63df702 100644 --- a/src/UnitConverter/Unit/Energy/Joule.php +++ b/src/UnitConverter/Unit/Energy/Joule.php @@ -31,7 +31,7 @@ protected function configure () : void $this ->setName("joule") - ->setSymbol("j") + ->setSymbol("J") ->setUnits(1) ; diff --git a/src/UnitConverter/Unit/Energy/WattHour.php b/src/UnitConverter/Unit/Energy/WattHour.php index d5591881..29524f1e 100644 --- a/src/UnitConverter/Unit/Energy/WattHour.php +++ b/src/UnitConverter/Unit/Energy/WattHour.php @@ -31,7 +31,7 @@ protected function configure () : void $this ->setName("watt hour") - ->setSymbol("whr") + ->setSymbol("Wh") ->setUnits(3600.0054468) ; From 6b9c0a0ccb6d82ffd42627410257618386c0ab24 Mon Sep 17 00:00:00 2001 From: andreboerema <1569403+andrewboerema@users.noreply.github.com> Date: Wed, 11 Oct 2017 12:31:49 -0500 Subject: [PATCH 2/3] Adding requested energy units --- src/UnitConverter/Unit/Energy/Kilojoule.php | 39 +++++++++++++++++++ .../Unit/Energy/KilowattHour.php | 39 +++++++++++++++++++ .../Unit/Energy/Megaelectronvolt.php | 39 +++++++++++++++++++ src/UnitConverter/Unit/Energy/Megajoule.php | 39 +++++++++++++++++++ .../Unit/Energy/MegawattHour.php | 39 +++++++++++++++++++ src/UnitConverter/Unit/Energy/NewtonMeter.php | 39 +++++++++++++++++++ 6 files changed, 234 insertions(+) create mode 100644 src/UnitConverter/Unit/Energy/Kilojoule.php create mode 100644 src/UnitConverter/Unit/Energy/KilowattHour.php create mode 100644 src/UnitConverter/Unit/Energy/Megaelectronvolt.php create mode 100644 src/UnitConverter/Unit/Energy/Megajoule.php create mode 100644 src/UnitConverter/Unit/Energy/MegawattHour.php create mode 100644 src/UnitConverter/Unit/Energy/NewtonMeter.php diff --git a/src/UnitConverter/Unit/Energy/Kilojoule.php b/src/UnitConverter/Unit/Energy/Kilojoule.php new file mode 100644 index 00000000..31b45df7 --- /dev/null +++ b/src/UnitConverter/Unit/Energy/Kilojoule.php @@ -0,0 +1,39 @@ + + * @license MIT + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types = 1); + +namespace UnitConverter\Unit\Energy; + +use UnitConverter\Measure; +use UnitConverter\Unit\{ AbstractUnit, UnitInterface }; + +/** + * Kilojoule unit data class. + * + * @version 1.0.0 + * @since 1.0.0 + * @author Andrew Boerema <1569403+andrewboerema@users.noreply.github.com> + */ +class Kilojoule extends EnergyUnit +{ + protected function configure () : void + { + $this + ->setName("kilojoule") + + ->setSymbol("kJ") + + ->setUnits(1000) + ; + } +} diff --git a/src/UnitConverter/Unit/Energy/KilowattHour.php b/src/UnitConverter/Unit/Energy/KilowattHour.php new file mode 100644 index 00000000..f39933f6 --- /dev/null +++ b/src/UnitConverter/Unit/Energy/KilowattHour.php @@ -0,0 +1,39 @@ + + * @license MIT + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types = 1); + +namespace UnitConverter\Unit\Energy; + +use UnitConverter\Measure; +use UnitConverter\Unit\{ AbstractUnit, UnitInterface }; + +/** + * KilowattHour unit data class. + * + * @version 1.0.0 + * @since 1.0.0 + * @author Andrew Boerema <1569403+andrewboerema@users.noreply.github.com> + */ +class KilowattHour extends EnergyUnit +{ + protected function configure () : void + { + $this + ->setName("kilowatt hour") + + ->setSymbol("kWh") + + ->setUnits(3600005.4468) + ; + } +} diff --git a/src/UnitConverter/Unit/Energy/Megaelectronvolt.php b/src/UnitConverter/Unit/Energy/Megaelectronvolt.php new file mode 100644 index 00000000..efc08e33 --- /dev/null +++ b/src/UnitConverter/Unit/Energy/Megaelectronvolt.php @@ -0,0 +1,39 @@ + + * @license MIT + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types = 1); + +namespace UnitConverter\Unit\Energy; + +use UnitConverter\Measure; +use UnitConverter\Unit\{ AbstractUnit, UnitInterface }; + +/** + * Megaelectronvolt unit data class. + * + * @version 1.0.0 + * @since 1.0.0 + * @author Andrew Boerema <1569403+andrewboerema@users.noreply.github.com> + */ +class Megaelectronvolt extends EnergyUnit +{ + protected function configure () : void + { + $this + ->setName("megaelectronvolt") + + ->setSymbol("MeV") + + ->setUnits(1.60218e-13) + ; + } +} diff --git a/src/UnitConverter/Unit/Energy/Megajoule.php b/src/UnitConverter/Unit/Energy/Megajoule.php new file mode 100644 index 00000000..50a4a786 --- /dev/null +++ b/src/UnitConverter/Unit/Energy/Megajoule.php @@ -0,0 +1,39 @@ + + * @license MIT + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types = 1); + +namespace UnitConverter\Unit\Energy; + +use UnitConverter\Measure; +use UnitConverter\Unit\{ AbstractUnit, UnitInterface }; + +/** + * Megajoule unit data class. + * + * @version 1.0.0 + * @since 1.0.0 + * @author Andrew Boerema <1569403+andrewboerema@users.noreply.github.com> + */ +class Megajoule extends EnergyUnit +{ + protected function configure () : void + { + $this + ->setName("megajoule") + + ->setSymbol("MJ") + + ->setUnits(1000000) + ; + } +} diff --git a/src/UnitConverter/Unit/Energy/MegawattHour.php b/src/UnitConverter/Unit/Energy/MegawattHour.php new file mode 100644 index 00000000..166e1b85 --- /dev/null +++ b/src/UnitConverter/Unit/Energy/MegawattHour.php @@ -0,0 +1,39 @@ + + * @license MIT + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types = 1); + +namespace UnitConverter\Unit\Energy; + +use UnitConverter\Measure; +use UnitConverter\Unit\{ AbstractUnit, UnitInterface }; + +/** + * MegawattHour unit data class. + * + * @version 1.0.0 + * @since 1.0.0 + * @author Andrew Boerema <1569403+andrewboerema@users.noreply.github.com> + */ +class MegawattHour extends EnergyUnit +{ + protected function configure () : void + { + $this + ->setName("megawatt hour") + + ->setSymbol("MWh") + + ->setUnits(3600005446.8) + ; + } +} diff --git a/src/UnitConverter/Unit/Energy/NewtonMeter.php b/src/UnitConverter/Unit/Energy/NewtonMeter.php new file mode 100644 index 00000000..e9e45429 --- /dev/null +++ b/src/UnitConverter/Unit/Energy/NewtonMeter.php @@ -0,0 +1,39 @@ + + * @license MIT + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types = 1); + +namespace UnitConverter\Unit\Energy; + +use UnitConverter\Measure; +use UnitConverter\Unit\{ AbstractUnit, UnitInterface }; + +/** + * NewtonMeter unit data class. + * + * @version 1.0.0 + * @since 1.0.0 + * @author Andrew Boerema <1569403+andrewboerema@users.noreply.github.com> + */ +class NewtonMeter extends EnergyUnit +{ + protected function configure () : void + { + $this + ->setName("newton meter") + + ->setSymbol("Nm") + + ->setUnits(1) + ; + } +} From ed9cbaf476f0d9ae4b04ffe5fb39c0e9eed13634 Mon Sep 17 00:00:00 2001 From: andreboerema <1569403+andrewboerema@users.noreply.github.com> Date: Wed, 11 Oct 2017 12:36:36 -0500 Subject: [PATCH 3/3] Removing unnecessary imports --- src/UnitConverter/Unit/Energy/Calorie.php | 3 --- src/UnitConverter/Unit/Energy/EnergyUnit.php | 2 +- src/UnitConverter/Unit/Energy/FootPound.php | 3 --- src/UnitConverter/Unit/Energy/Joule.php | 3 --- src/UnitConverter/Unit/Energy/Kilojoule.php | 3 --- src/UnitConverter/Unit/Energy/KilowattHour.php | 3 --- src/UnitConverter/Unit/Energy/Megaelectronvolt.php | 3 --- src/UnitConverter/Unit/Energy/Megajoule.php | 3 --- src/UnitConverter/Unit/Energy/MegawattHour.php | 3 --- src/UnitConverter/Unit/Energy/NewtonMeter.php | 3 --- src/UnitConverter/Unit/Energy/WattHour.php | 3 --- 11 files changed, 1 insertion(+), 31 deletions(-) diff --git a/src/UnitConverter/Unit/Energy/Calorie.php b/src/UnitConverter/Unit/Energy/Calorie.php index 14cc7998..a5847681 100644 --- a/src/UnitConverter/Unit/Energy/Calorie.php +++ b/src/UnitConverter/Unit/Energy/Calorie.php @@ -14,9 +14,6 @@ namespace UnitConverter\Unit\Energy; -use UnitConverter\Measure; -use UnitConverter\Unit\{ AbstractUnit, UnitInterface }; - /** * Calorie unit data class. * diff --git a/src/UnitConverter/Unit/Energy/EnergyUnit.php b/src/UnitConverter/Unit/Energy/EnergyUnit.php index 09a98b6b..787925d7 100644 --- a/src/UnitConverter/Unit/Energy/EnergyUnit.php +++ b/src/UnitConverter/Unit/Energy/EnergyUnit.php @@ -15,7 +15,7 @@ namespace UnitConverter\Unit\Energy; use UnitConverter\Measure; -use UnitConverter\Unit\{ AbstractUnit, UnitInterface }; +use UnitConverter\Unit\{ AbstractUnit }; /** * Energy base data class. Any new energy units should diff --git a/src/UnitConverter/Unit/Energy/FootPound.php b/src/UnitConverter/Unit/Energy/FootPound.php index 9ca2126b..0d6a9518 100644 --- a/src/UnitConverter/Unit/Energy/FootPound.php +++ b/src/UnitConverter/Unit/Energy/FootPound.php @@ -14,9 +14,6 @@ namespace UnitConverter\Unit\Energy; -use UnitConverter\Measure; -use UnitConverter\Unit\{ AbstractUnit, UnitInterface }; - /** * FootPound unit data class. * diff --git a/src/UnitConverter/Unit/Energy/Joule.php b/src/UnitConverter/Unit/Energy/Joule.php index d63df702..d5701f81 100644 --- a/src/UnitConverter/Unit/Energy/Joule.php +++ b/src/UnitConverter/Unit/Energy/Joule.php @@ -14,9 +14,6 @@ namespace UnitConverter\Unit\Energy; -use UnitConverter\Measure; -use UnitConverter\Unit\{ AbstractUnit, UnitInterface }; - /** * Joule unit data class. * diff --git a/src/UnitConverter/Unit/Energy/Kilojoule.php b/src/UnitConverter/Unit/Energy/Kilojoule.php index 31b45df7..91619fe8 100644 --- a/src/UnitConverter/Unit/Energy/Kilojoule.php +++ b/src/UnitConverter/Unit/Energy/Kilojoule.php @@ -14,9 +14,6 @@ namespace UnitConverter\Unit\Energy; -use UnitConverter\Measure; -use UnitConverter\Unit\{ AbstractUnit, UnitInterface }; - /** * Kilojoule unit data class. * diff --git a/src/UnitConverter/Unit/Energy/KilowattHour.php b/src/UnitConverter/Unit/Energy/KilowattHour.php index f39933f6..bd89205e 100644 --- a/src/UnitConverter/Unit/Energy/KilowattHour.php +++ b/src/UnitConverter/Unit/Energy/KilowattHour.php @@ -14,9 +14,6 @@ namespace UnitConverter\Unit\Energy; -use UnitConverter\Measure; -use UnitConverter\Unit\{ AbstractUnit, UnitInterface }; - /** * KilowattHour unit data class. * diff --git a/src/UnitConverter/Unit/Energy/Megaelectronvolt.php b/src/UnitConverter/Unit/Energy/Megaelectronvolt.php index efc08e33..e827ee89 100644 --- a/src/UnitConverter/Unit/Energy/Megaelectronvolt.php +++ b/src/UnitConverter/Unit/Energy/Megaelectronvolt.php @@ -14,9 +14,6 @@ namespace UnitConverter\Unit\Energy; -use UnitConverter\Measure; -use UnitConverter\Unit\{ AbstractUnit, UnitInterface }; - /** * Megaelectronvolt unit data class. * diff --git a/src/UnitConverter/Unit/Energy/Megajoule.php b/src/UnitConverter/Unit/Energy/Megajoule.php index 50a4a786..6349788c 100644 --- a/src/UnitConverter/Unit/Energy/Megajoule.php +++ b/src/UnitConverter/Unit/Energy/Megajoule.php @@ -14,9 +14,6 @@ namespace UnitConverter\Unit\Energy; -use UnitConverter\Measure; -use UnitConverter\Unit\{ AbstractUnit, UnitInterface }; - /** * Megajoule unit data class. * diff --git a/src/UnitConverter/Unit/Energy/MegawattHour.php b/src/UnitConverter/Unit/Energy/MegawattHour.php index 166e1b85..b102b127 100644 --- a/src/UnitConverter/Unit/Energy/MegawattHour.php +++ b/src/UnitConverter/Unit/Energy/MegawattHour.php @@ -14,9 +14,6 @@ namespace UnitConverter\Unit\Energy; -use UnitConverter\Measure; -use UnitConverter\Unit\{ AbstractUnit, UnitInterface }; - /** * MegawattHour unit data class. * diff --git a/src/UnitConverter/Unit/Energy/NewtonMeter.php b/src/UnitConverter/Unit/Energy/NewtonMeter.php index e9e45429..c37c7e12 100644 --- a/src/UnitConverter/Unit/Energy/NewtonMeter.php +++ b/src/UnitConverter/Unit/Energy/NewtonMeter.php @@ -14,9 +14,6 @@ namespace UnitConverter\Unit\Energy; -use UnitConverter\Measure; -use UnitConverter\Unit\{ AbstractUnit, UnitInterface }; - /** * NewtonMeter unit data class. * diff --git a/src/UnitConverter/Unit/Energy/WattHour.php b/src/UnitConverter/Unit/Energy/WattHour.php index 29524f1e..7bc074f7 100644 --- a/src/UnitConverter/Unit/Energy/WattHour.php +++ b/src/UnitConverter/Unit/Energy/WattHour.php @@ -14,9 +14,6 @@ namespace UnitConverter\Unit\Energy; -use UnitConverter\Measure; -use UnitConverter\Unit\{ AbstractUnit, UnitInterface }; - /** * WattHour unit data class. *