-
Notifications
You must be signed in to change notification settings - Fork 0
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 brewerwall/feature/unit-service
New UnitzService
- Loading branch information
Showing
12 changed files
with
263 additions
and
32 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,32 @@ | ||
on: | ||
push: | ||
branches: | ||
- "feature/**" | ||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Validate composer.json and composer.lock | ||
run: composer validate --strict | ||
|
||
- name: Cache Composer packages | ||
id: composer-cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: vendor | ||
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-php- | ||
- name: Install dependencies | ||
run: composer install --prefer-dist --no-progress | ||
|
||
- name: Run test suite | ||
run: composer run-script test |
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
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,27 @@ | ||
<?php | ||
|
||
namespace Unitz; | ||
|
||
class BaseUnitz | ||
{ | ||
public const DEFAULT_PREFERENCES = [ | ||
'Gravity' => 'Plato', | ||
'Temperature' => 'Fahrenheit', | ||
'Volume' => 'Gallon', | ||
'Pressure' => 'Psi', | ||
'Weight' => 'Pound', | ||
'Color' => 'Srm', | ||
]; | ||
|
||
private array $preferences; | ||
|
||
public function __construct(array $preferences = []) | ||
{ | ||
$this->preferences = array_merge(self::DEFAULT_PREFERENCES, $preferences); | ||
} | ||
|
||
public function getPreferences(): array | ||
{ | ||
return $this->preferences; | ||
} | ||
} |
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
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
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,84 @@ | ||
<?php | ||
|
||
namespace Unitz; | ||
|
||
final class UnitzService extends BaseUnitz | ||
{ | ||
/** | ||
* @param float|null $srm | ||
* @param float|null $ebc | ||
* @param float|null $lovibond | ||
* @return \Unitz\Color | ||
*/ | ||
public function makeColor(?float $srm = null, ?float $ebc = null, ?float $lovibond = null): Color | ||
{ | ||
return new Color($srm, $ebc, $lovibond, $this->getPreferences()); | ||
} | ||
|
||
/** | ||
* @param float|null $plato | ||
* @param float|null $specificGravity | ||
* @param float|null $brix | ||
* @return \Unitz\Gravity | ||
*/ | ||
public function makeGravity(?float $plato = null, ?float $specificGravity = null, ?float $brix = null): Gravity | ||
{ | ||
return new Gravity($plato, $specificGravity, $brix, $this->getPreferences()); | ||
} | ||
|
||
/** | ||
* @param float|null $bar | ||
* @param float|null $psi | ||
* @return \Unitz\Pressure | ||
*/ | ||
public function makePressure(?float $bar = null, ?float $psi = null): Pressure | ||
{ | ||
return new Pressure($bar, $psi, $this->getPreferences()); | ||
} | ||
|
||
/** | ||
* @param float|null $fahrenheit | ||
* * @param float|null $celsius | ||
* @return \Unitz\Temperature | ||
*/ | ||
public function makeTemperature(?float $fahrenheit = null, ?float $celsius = null): Temperature | ||
{ | ||
return new Temperature($fahrenheit, $celsius, $this->getPreferences()); | ||
} | ||
|
||
/** | ||
* @param float|null $ounce | ||
* @param float|null $gallon | ||
* @param float|null $barrel | ||
* @param float|null $milliliter | ||
* @param float|null $liter | ||
* @param float|null $hectoliter | ||
* @return \Unitz\Volume | ||
*/ | ||
public function makeVolume( | ||
float $ounce = null, | ||
float $gallon = null, | ||
float $barrel = null, | ||
float $milliliter = null, | ||
float $liter = null, | ||
float $hectoliter = null | ||
): Volume { | ||
return new Volume($ounce, $gallon, $barrel, $milliliter, $liter, $hectoliter, $this->getPreferences()); | ||
} | ||
|
||
/** | ||
* @param float|null $ounce | ||
* @param float|null $pound | ||
* @param float|null $gram | ||
* @param float|null $kilogram | ||
* @return \Unitz\Weight | ||
*/ | ||
public function makeWeight( | ||
?float $ounce = null, | ||
?float $pound = null, | ||
?float $gram = null, | ||
?float $kilogram = null, | ||
): Weight { | ||
return new Weight($ounce, $pound, $gram, $kilogram, $this->getPreferences()); | ||
} | ||
} |
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.