-
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.
Merge pull request #1 from jordanbrauer/develop
MVP version of component
- Loading branch information
Showing
31 changed files
with
1,868 additions
and
12 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,48 @@ | ||
<?php | ||
|
||
error_reporting(E_ALL); | ||
ini_set('display_errors', 1); | ||
|
||
require_once "vendor/autoload.php"; | ||
|
||
use UnitConverter\UnitConverter; | ||
use UnitConverter\Registry\UnitRegistry; | ||
use UnitConverter\Unit\AbstractUnit; | ||
use UnitConverter\Measure; | ||
use UnitConverter\Unit\Length\{ | ||
Centimeter, | ||
Inch | ||
}; | ||
|
||
# Configuring a New Converter | ||
# =========================== | ||
|
||
$units = array( | ||
new Centimeter, | ||
new Inch, | ||
); | ||
|
||
$registry = new UnitRegistry($units); | ||
|
||
$converter = new UnitConverter($registry); | ||
|
||
# Registering Custom Units | ||
# ======================== | ||
|
||
$registry->registerUnit(new class extends AbstractUnit { | ||
protected $name = "testtt"; | ||
protected $symbol = "Tst"; | ||
protected $unitOf = Measure::VOLUME; | ||
protected $base = self::class; | ||
protected $units = 1; | ||
}); | ||
|
||
# Converting Units | ||
# ================ | ||
|
||
$conversion = | ||
$converter | ||
->convert(1) | ||
->from("in") | ||
->to("cm") | ||
; |
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
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,46 @@ | ||
<?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; | ||
|
||
/** | ||
* A static class containing constants that define the available | ||
* default types of measurement. | ||
* | ||
* @version 1.0.0 | ||
* @since 1.0.0 | ||
* @author Jordan Brauer <[email protected]> | ||
*/ | ||
class Measure | ||
{ | ||
const LENGTH = "length"; | ||
|
||
const AREA = "area"; | ||
|
||
const VOLUME = "volume"; | ||
|
||
const WEIGHT = "weight"; | ||
|
||
const SPEED = "speed"; | ||
|
||
const ROTATION = "rotation"; | ||
|
||
const TEMPERATURE = "temperature"; | ||
|
||
const PRESSURE = "pressure"; | ||
|
||
const TIME = "time"; | ||
|
||
const ENERGY = "energy"; | ||
} |
Oops, something went wrong.