hiqdev /
php-billing
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * PHP Billing Library |
||
| 4 | * |
||
| 5 | * @link https://github.com/hiqdev/php-billing |
||
| 6 | * @package php-billing |
||
| 7 | * @license BSD-3-Clause |
||
| 8 | * @copyright Copyright (c) 2017-2020, HiQDev (http://hiqdev.com/) |
||
| 9 | */ |
||
| 10 | |||
| 11 | namespace hiqdev\php\billing\price; |
||
| 12 | |||
| 13 | use hiqdev\php\billing\plan\PlanInterface; |
||
| 14 | use hiqdev\php\billing\target\TargetInterface; |
||
| 15 | use hiqdev\php\billing\type\TypeInterface; |
||
|
0 ignored issues
–
show
|
|||
| 16 | use hiqdev\php\units\Quantity; |
||
| 17 | use hiqdev\php\units\QuantityInterface; |
||
| 18 | use Money\Money; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Single Price. |
||
| 22 | * |
||
| 23 | * - no charge for quantity less then prepaid |
||
| 24 | * - same price for any quantity above prepaid |
||
| 25 | * |
||
| 26 | * @see PriceInterface |
||
| 27 | * |
||
| 28 | * @author Andrii Vasyliev <[email protected]> |
||
| 29 | */ |
||
| 30 | class SinglePrice extends AbstractPrice implements PriceWithQuantityInterface, PriceWithMoneyInterface |
||
| 31 | { |
||
| 32 | use HasMoney; |
||
| 33 | use HasQuantity; |
||
| 34 | |||
| 35 | public function __construct( |
||
| 36 | $id, |
||
| 37 | TypeInterface $type, |
||
| 38 | TargetInterface $target, |
||
| 39 | PlanInterface $plan = null, |
||
| 40 | QuantityInterface $prepaid, |
||
| 41 | Money $price |
||
| 42 | 39 | ) { |
|
| 43 | parent::__construct($id, $type, $target, $plan); |
||
| 44 | $this->prepaid = $prepaid; |
||
| 45 | $this->price = $price; |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * {@inheritdoc} |
||
| 50 | 39 | */ |
|
| 51 | 39 | public function calculateUsage(QuantityInterface $quantity): ?QuantityInterface |
|
| 52 | 39 | { |
|
| 53 | 39 | $usage = $quantity->convert($this->prepaid->getUnit())->subtract($this->prepaid); |
|
| 54 | |||
| 55 | 3 | if ($usage->isPositive()) { |
|
| 56 | return $usage; |
||
| 57 | 3 | } |
|
| 58 | |||
| 59 | return Quantity::create($this->prepaid->getUnit()->getName(), 0); |
||
| 60 | 3 | } |
|
| 61 | |||
| 62 | 3 | /** |
|
| 63 | * {@inheritdoc} |
||
| 64 | * Same price for any usage. |
||
| 65 | */ |
||
| 66 | public function calculatePrice(QuantityInterface $quantity): ?Money |
||
| 67 | { |
||
| 68 | 18 | return $this->price; |
|
| 69 | } |
||
| 70 | } |
||
| 71 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths