diff --git a/src/UnitConverter/Unit/Time/Day.php b/src/UnitConverter/Unit/Time/Day.php new file mode 100644 index 00000000..c61dba73 --- /dev/null +++ b/src/UnitConverter/Unit/Time/Day.php @@ -0,0 +1,36 @@ + + * @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\Time; + +/** + * Day unit data class. + * + * @version 1.0.0 + * @since 1.0.0 + * @author Teun Willems + */ +class Day extends TimeUnit +{ + protected function configure () : void + { + $this + ->setName("day") + + ->setSymbol("day") + + ->setUnits(86400) + ; + } +} diff --git a/src/UnitConverter/Unit/Time/Hour.php b/src/UnitConverter/Unit/Time/Hour.php new file mode 100644 index 00000000..6867427d --- /dev/null +++ b/src/UnitConverter/Unit/Time/Hour.php @@ -0,0 +1,36 @@ + + * @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\Time; + +/** + * Hour unit data class. + * + * @version 1.0.0 + * @since 1.0.0 + * @author Teun Willems + */ +class Hour extends TimeUnit +{ + protected function configure () : void + { + $this + ->setName("hour") + + ->setSymbol("hr") + + ->setUnits(3600) + ; + } +} diff --git a/src/UnitConverter/Unit/Time/Microsecond.php b/src/UnitConverter/Unit/Time/Microsecond.php new file mode 100644 index 00000000..f6e84cea --- /dev/null +++ b/src/UnitConverter/Unit/Time/Microsecond.php @@ -0,0 +1,36 @@ + + * @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\Time; + +/** + * Microsecond unit data class. + * + * @version 1.0.0 + * @since 1.0.0 + * @author Teun Willems + */ +class Microsecond extends TimeUnit +{ + protected function configure () : void + { + $this + ->setName("microsecond") + + ->setSymbol("μs") + + ->setUnits(0.000001) + ; + } +} diff --git a/src/UnitConverter/Unit/Time/Millisecond.php b/src/UnitConverter/Unit/Time/Millisecond.php new file mode 100644 index 00000000..54842346 --- /dev/null +++ b/src/UnitConverter/Unit/Time/Millisecond.php @@ -0,0 +1,36 @@ + + * @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\Time; + +/** + * Millisecond unit data class. + * + * @version 1.0.0 + * @since 1.0.0 + * @author Teun Willems + */ +class Millisecond extends TimeUnit +{ + protected function configure () : void + { + $this + ->setName("millisecond") + + ->setSymbol("ms") + + ->setUnits(0.001) + ; + } +} diff --git a/src/UnitConverter/Unit/Time/Minute.php b/src/UnitConverter/Unit/Time/Minute.php new file mode 100644 index 00000000..9fe1b75b --- /dev/null +++ b/src/UnitConverter/Unit/Time/Minute.php @@ -0,0 +1,36 @@ + + * @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\Time; + +/** + * Minute unit data class. + * + * @version 1.0.0 + * @since 1.0.0 + * @author Teun Willems + */ +class Minute extends TimeUnit +{ + protected function configure () : void + { + $this + ->setName("minute") + + ->setSymbol("min") + + ->setUnits(60) + ; + } +} diff --git a/src/UnitConverter/Unit/Time/Month.php b/src/UnitConverter/Unit/Time/Month.php new file mode 100644 index 00000000..4eabccf5 --- /dev/null +++ b/src/UnitConverter/Unit/Time/Month.php @@ -0,0 +1,36 @@ + + * @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\Time; + +/** + * Month unit data class. + * + * @version 1.0.0 + * @since 1.0.0 + * @author Teun Willems + */ +class Month extends TimeUnit +{ + protected function configure () : void + { + $this + ->setName("month") + + ->setSymbol("month") + + ->setUnits(2678400) + ; + } +} diff --git a/src/UnitConverter/Unit/Time/Nanosecond.php b/src/UnitConverter/Unit/Time/Nanosecond.php new file mode 100644 index 00000000..cfdde003 --- /dev/null +++ b/src/UnitConverter/Unit/Time/Nanosecond.php @@ -0,0 +1,36 @@ + + * @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\Time; + +/** + * Nanosecond unit data class. + * + * @version 1.0.0 + * @since 1.0.0 + * @author Teun Willems + */ +class Nanosecond extends TimeUnit +{ + protected function configure () : void + { + $this + ->setName("nanosecond") + + ->setSymbol("ns") + + ->setUnits(0.000000001) + ; + } +} diff --git a/src/UnitConverter/Unit/Time/Second.php b/src/UnitConverter/Unit/Time/Second.php new file mode 100644 index 00000000..3ad81e59 --- /dev/null +++ b/src/UnitConverter/Unit/Time/Second.php @@ -0,0 +1,36 @@ + + * @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\Time; + +/** + * Second unit data class. + * + * @version 1.0.0 + * @since 1.0.0 + * @author Teun Willems + */ +class Second extends TimeUnit +{ + protected function configure () : void + { + $this + ->setName("second") + + ->setSymbol("s") + + ->setUnits(1) + ; + } +} diff --git a/src/UnitConverter/Unit/Time/TimeUnit.php b/src/UnitConverter/Unit/Time/TimeUnit.php new file mode 100644 index 00000000..7fbc6f54 --- /dev/null +++ b/src/UnitConverter/Unit/Time/TimeUnit.php @@ -0,0 +1,34 @@ + + * @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\Time; + +use UnitConverter\Measure; +use UnitConverter\Unit\AbstractUnit; + +/** + * Time base class, new time classes should be extending this class + * implenting their name, symbol and units + * Only override $unitOf and $base properties when necessary + * + * @version 1.0.0 + * @since 1.0.0 + * @author Teun Willems + */ +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 new file mode 100644 index 00000000..691a3af8 --- /dev/null +++ b/src/UnitConverter/Unit/Time/Week.php @@ -0,0 +1,36 @@ + + * @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\Time; + +/** + * Week unit data class. + * + * @version 1.0.0 + * @since 1.0.0 + * @author Teun Willems + */ +class Week extends TimeUnit +{ + protected function configure () : void + { + $this + ->setName("week") + + ->setSymbol("week") + + ->setUnits(604800) + ; + } +} diff --git a/src/UnitConverter/Unit/Time/Year.php b/src/UnitConverter/Unit/Time/Year.php new file mode 100644 index 00000000..8f99063f --- /dev/null +++ b/src/UnitConverter/Unit/Time/Year.php @@ -0,0 +1,36 @@ + + * @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\Time; + +/** + * Year unit data class. + * + * @version 1.0.0 + * @since 1.0.0 + * @author Teun Willems + */ +class Year extends TimeUnit +{ + protected function configure () : void + { + $this + ->setName("year") + + ->setSymbol("year") + + ->setUnits(31536000) + ; + } +}