-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added Speed Units * added force units * Pressure Units * Add volumetric flow * Added quotient * Added translations * Removed light year --------- Signed-off-by: Vinzenz Rosenkranz <[email protected]> Co-authored-by: Vinzenz Rosenkranz <[email protected]>
- Loading branch information
Showing
15 changed files
with
1,654 additions
and
1,405 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,17 @@ | ||
<?php | ||
|
||
namespace App\AttributeTypes\Units\Implementations; | ||
|
||
use App\AttributeTypes\Units\Constants\Si; | ||
use App\AttributeTypes\Units\Unit; | ||
use App\AttributeTypes\Units\UnitSystem; | ||
use App\AttributeTypes\Units\UnitType; | ||
|
||
class ForceUnits extends UnitSystem { | ||
public function __construct() { | ||
parent::__construct('force', [ | ||
Unit::createBase('newton' , 'N' ), | ||
Unit::createUnit('kilonewton', 'kN', Si::KILO, 1, UnitType::SI), | ||
]); | ||
} | ||
} |
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
35 changes: 35 additions & 0 deletions
35
app/AttributeTypes/Units/Implementations/PressureUnits.php
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,35 @@ | ||
<?php | ||
|
||
namespace App\AttributeTypes\Units\Implementations; | ||
|
||
use App\AttributeTypes\Units\Call; | ||
use App\AttributeTypes\Units\Constants\Si; | ||
use App\AttributeTypes\Units\Unit; | ||
use App\AttributeTypes\Units\UnitSystem; | ||
use App\AttributeTypes\Units\UnitType; | ||
|
||
class PressureUnits extends UnitSystem { | ||
public function __construct() { | ||
// Pascal | ||
parent::__construct('pressure', [ | ||
Unit::createBase('pascal' , 'Pa' ), | ||
Unit::createUnit('kilopascal' , 'kPa', Si::KILO, 1, UnitType::SI), | ||
Unit::createUnit('hectopascal', 'hPa', Si::HECTO, 1, UnitType::SI), | ||
]); | ||
|
||
// Bar | ||
$this->addMultiple([ | ||
Unit::createUnit('bar' , 'bar' , 1e5), | ||
Unit::createUnit('decibar' , 'dbar', 1e4), // Used in oceanography | ||
Unit::createUnit('millibar', 'mbar', 1e2), | ||
]); | ||
|
||
// Various | ||
$this->addMultiple([ | ||
Unit::createUnit('pound_per_square_inch', 'psi' , 6894.757), | ||
Unit::createUnit('torr' , 'Torr', 133.3224), | ||
Unit::createUnit('technical_atmosphere' , 'at' , 98066.5 ), | ||
Unit::createUnit('standard_atmosphere' , 'atm' , 101325 ), | ||
]); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
app/AttributeTypes/Units/Implementations/QuotientUnits.php
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,18 @@ | ||
<?php | ||
|
||
namespace App\AttributeTypes\Units\Implementations; | ||
|
||
use App\AttributeTypes\Units\Unit; | ||
use App\AttributeTypes\Units\UnitSystem; | ||
|
||
class QuotientUnits extends UnitSystem | ||
{ | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct('quotient', [ | ||
Unit::createUnit('percent' , '%' , 1e4), | ||
Unit::createBase('parts per million', 'ppm' ), | ||
]); | ||
} | ||
} |
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,24 @@ | ||
<?php | ||
|
||
namespace App\AttributeTypes\Units\Implementations; | ||
|
||
use App\AttributeTypes\Units\Unit; | ||
use App\AttributeTypes\Units\UnitSystem; | ||
|
||
class SpeedUnits extends UnitSystem { | ||
|
||
public function __construct() { | ||
parent::__construct('speed', [ | ||
Unit::createBase('metre_per_second' , 'm/s' ), | ||
Unit::createUnit('kilometre_per_hour', 'km/h' , self::factorFromTimeAndLengthUnits('hour', 'kilometre')), | ||
Unit::createUnit('mile_per_hour' , 'mph' , self::factorFromTimeAndLengthUnits('hour', 'mile') ), | ||
]); | ||
} | ||
|
||
public static function factorFromTimeAndLengthUnits(string $time, string $length) : float { | ||
$lengthUnits = new LengthUnits(); | ||
$timeUnits = new TimeUnits(); | ||
|
||
return $lengthUnits->getByLabel($length)->is(1) / $timeUnits->getByLabel($time)->is(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
16 changes: 16 additions & 0 deletions
16
app/AttributeTypes/Units/Implementations/VolumetricFlowUnits.php
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,16 @@ | ||
<?php | ||
|
||
namespace App\AttributeTypes\Units\Implementations; | ||
|
||
use App\AttributeTypes\Units\Constants\Si; | ||
use App\AttributeTypes\Units\Unit; | ||
use App\AttributeTypes\Units\UnitSystem; | ||
|
||
class VolumetricFlowUnits extends UnitSystem { | ||
public function __construct() { | ||
parent::__construct('volumetric_flow', [ | ||
Unit::createBase('cubic_metre_per_second', 'm³/s' ), | ||
Unit::createUnit('litre_per_second' , 'l/s' , 10 ** (Si::DECI * 3)), | ||
]); | ||
} | ||
} |
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
Oops, something went wrong.