Conditions | 4 |
Paths | 3 |
Total Lines | 13 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | 4 | public function decrement(string $key, int|float $amount = 1): static |
|
23 | { |
||
24 | 4 | $value = $this->getAttribute($key); |
|
25 | |||
26 | 4 | if ($value && !is_numeric($value)) { |
|
27 | 2 | throw new \InvalidArgumentException("Value of key [{$key}] is not numeric"); |
|
28 | } |
||
29 | |||
30 | 2 | if (!$value) { |
|
31 | 2 | $value = 0; |
|
32 | } |
||
33 | |||
34 | 2 | return $this->setAttribute($key, $value - $amount); |
|
35 | } |
||
37 |