-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #10 * Added time measurements * Added requested changes * Added new time units
- Loading branch information
1 parent
707fb0a
commit 611293e
Showing
11 changed files
with
394 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
; | ||
} | ||
} |
Oops, something went wrong.