Skip to content

Commit

Permalink
Added time measurements (#35)
Browse files Browse the repository at this point in the history
Closes #10 

* Added time measurements

* Added requested changes

* Added new time units
  • Loading branch information
teunw authored and jordanbrauer committed Oct 12, 2017
1 parent 707fb0a commit 611293e
Show file tree
Hide file tree
Showing 11 changed files with 394 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/UnitConverter/Unit/Time/Day.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/**
* This file is part of the jordanbrauer/unit-converter PHP package.
*
* @copyright 2017 Jordan Brauer <[email protected]>
* @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)
;
}
}
36 changes: 36 additions & 0 deletions src/UnitConverter/Unit/Time/Hour.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/**
* This file is part of the jordanbrauer/unit-converter PHP package.
*
* @copyright 2017 Jordan Brauer <[email protected]>
* @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)
;
}
}
36 changes: 36 additions & 0 deletions src/UnitConverter/Unit/Time/Microsecond.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/**
* This file is part of the jordanbrauer/unit-converter PHP package.
*
* @copyright 2017 Jordan Brauer <[email protected]>
* @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)
;
}
}
36 changes: 36 additions & 0 deletions src/UnitConverter/Unit/Time/Millisecond.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/**
* This file is part of the jordanbrauer/unit-converter PHP package.
*
* @copyright 2017 Jordan Brauer <[email protected]>
* @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)
;
}
}
36 changes: 36 additions & 0 deletions src/UnitConverter/Unit/Time/Minute.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/**
* This file is part of the jordanbrauer/unit-converter PHP package.
*
* @copyright 2017 Jordan Brauer <[email protected]>
* @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)
;
}
}
36 changes: 36 additions & 0 deletions src/UnitConverter/Unit/Time/Month.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/**
* This file is part of the jordanbrauer/unit-converter PHP package.
*
* @copyright 2017 Jordan Brauer <[email protected]>
* @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)
;
}
}
36 changes: 36 additions & 0 deletions src/UnitConverter/Unit/Time/Nanosecond.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/**
* This file is part of the jordanbrauer/unit-converter PHP package.
*
* @copyright 2017 Jordan Brauer <[email protected]>
* @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)
;
}
}
36 changes: 36 additions & 0 deletions src/UnitConverter/Unit/Time/Second.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/**
* This file is part of the jordanbrauer/unit-converter PHP package.
*
* @copyright 2017 Jordan Brauer <[email protected]>
* @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)
;
}
}
34 changes: 34 additions & 0 deletions src/UnitConverter/Unit/Time/TimeUnit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/**
* This file is part of the jordanbrauer/unit-converter PHP package.
*
* @copyright 2017 Jordan Brauer <[email protected]>
* @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;
}
36 changes: 36 additions & 0 deletions src/UnitConverter/Unit/Time/Week.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/**
* This file is part of the jordanbrauer/unit-converter PHP package.
*
* @copyright 2017 Jordan Brauer <[email protected]>
* @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)
;
}
}
Loading

0 comments on commit 611293e

Please sign in to comment.