-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update namespace for interfaces and refactor constants
Moved interface files to Contracts directory for better organization. Refactored magic numbers in codes to use constants from new FiguresInterface for improved readability. Test cases and documentation were updated accordingly. Signed-off-by: Marcel Strahl <[email protected]>
- Loading branch information
1 parent
9d56410
commit f234ba4
Showing
46 changed files
with
202 additions
and
87 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
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
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,33 @@ | ||
{ | ||
"$schema": "vendor/infection/infection/resources/schema.json", | ||
"source": { | ||
"directories": [ | ||
"src" | ||
], | ||
"excludes": [ | ||
"src/Helpers/Mathematics.php" | ||
] | ||
}, | ||
"mutators": { | ||
"@default": true, | ||
"BCMath": { | ||
"settings": { | ||
"bcdiv": false, | ||
"bcmul": false, | ||
"bcadd": false, | ||
"bcsub": false | ||
} | ||
}, | ||
}, | ||
"logs": { | ||
"html": "infection.html", | ||
"summary": "summary.log", | ||
"json": "infection-log.json", | ||
"perMutator": "per-mutator.md", | ||
"github": true, | ||
"stryker": { | ||
"badge": "master" | ||
}, | ||
"summaryJson": "summary.json" | ||
}, | ||
} |
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
declare(strict_types=1); | ||
|
||
namespace MarcelStrahl\PriceCalculator\Helpers\Converter; | ||
namespace MarcelStrahl\PriceCalculator\Contracts\Converter; | ||
|
||
/** | ||
* @author Marcel Strahl <[email protected]> | ||
|
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 |
---|---|---|
|
@@ -2,10 +2,10 @@ | |
|
||
declare(strict_types=1); | ||
|
||
namespace MarcelStrahl\PriceCalculator\Factory; | ||
namespace MarcelStrahl\PriceCalculator\Contracts\Factory; | ||
|
||
use MarcelStrahl\PriceCalculator\Contracts\Converter\ConverterInterface; | ||
use MarcelStrahl\PriceCalculator\Exceptions\PriceCalculatorFactoryException; | ||
use MarcelStrahl\PriceCalculator\Helpers\Converter\ConverterInterface; | ||
|
||
/** | ||
* @author Marcel Strahl <[email protected]> | ||
|
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,16 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace MarcelStrahl\PriceCalculator\Contracts\Type; | ||
|
||
interface FiguresInterface | ||
{ | ||
public const INTEGER_ZERO = 0; | ||
public const INTEGER_ONE = 1; | ||
public const INTEGER_TWO = 2; | ||
public const INTEGER_HUNDRED = 100; | ||
|
||
public const FLOAT_ZERO = .0; | ||
|
||
public const STRING_HUNDRED = '100'; | ||
} |
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
declare(strict_types=1); | ||
|
||
namespace MarcelStrahl\PriceCalculator\Helpers\Types; | ||
namespace MarcelStrahl\PriceCalculator\Contracts\Type; | ||
|
||
/** | ||
* @author Marcel Strahl <[email protected]> | ||
|
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 |
---|---|---|
|
@@ -2,9 +2,9 @@ | |
|
||
declare(strict_types=1); | ||
|
||
namespace MarcelStrahl\PriceCalculator; | ||
namespace MarcelStrahl\PriceCalculator\Contracts; | ||
|
||
use MarcelStrahl\PriceCalculator\Helpers\Converter\ConverterInterface; | ||
use MarcelStrahl\PriceCalculator\Contracts\Converter\ConverterInterface; | ||
|
||
/** | ||
* @author Marcel Strahl <[email protected]> | ||
|
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 |
---|---|---|
|
@@ -2,12 +2,10 @@ | |
|
||
declare(strict_types=1); | ||
|
||
namespace MarcelStrahl\PriceCalculator\Helpers\View; | ||
namespace MarcelStrahl\PriceCalculator\Contracts\View; | ||
|
||
/** | ||
* Interface Formatter | ||
* @author Marcel Strahl <[email protected]> | ||
* @package Src\Helpers\View | ||
*/ | ||
interface Formatter | ||
{ | ||
|
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 |
---|---|---|
|
@@ -4,8 +4,8 @@ | |
|
||
namespace MarcelStrahl\PriceCalculator\Facade; | ||
|
||
use MarcelStrahl\PriceCalculator\Contracts\PriceCalculatorInterface; | ||
use MarcelStrahl\PriceCalculator\PriceCalculator as PriceCalculatorService; | ||
use MarcelStrahl\PriceCalculator\PriceCalculatorInterface; | ||
|
||
/** | ||
* @author Marcel Strahl <[email protected]> | ||
|
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 |
---|---|---|
|
@@ -4,7 +4,8 @@ | |
|
||
namespace MarcelStrahl\PriceCalculator\Helpers\Converter\Currencies; | ||
|
||
use MarcelStrahl\PriceCalculator\Helpers\Converter\ConverterInterface; | ||
use MarcelStrahl\PriceCalculator\Contracts\Converter\ConverterInterface; | ||
use MarcelStrahl\PriceCalculator\Contracts\Type\FiguresInterface; | ||
|
||
/** | ||
* @author Marcel Strahl <[email protected]> | ||
|
@@ -17,17 +18,17 @@ class CentToEuro implements ConverterInterface | |
public function convert(float $amount): float | ||
{ | ||
if ($this->isEmpty($amount)) { | ||
return .0; | ||
return FiguresInterface::FLOAT_ZERO; | ||
} | ||
|
||
return (float) bcdiv((string) $amount, '100', 2); | ||
return (float) bcdiv((string) $amount, FiguresInterface::STRING_HUNDRED, FiguresInterface::INTEGER_TWO); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function isEmpty(float $amount): bool | ||
{ | ||
return empty($amount) || $amount < 0; | ||
return empty($amount); | ||
} | ||
} |
Oops, something went wrong.