| 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 |
||
| 7 | 4 | public function increment(string $key, int|float $amount = 1): static |
|
| 8 | { |
||
| 9 | 4 | $value = $this->getAttribute($key); |
|
|
|
|||
| 10 | |||
| 11 | 4 | if ($value && !is_numeric($value)) { |
|
| 12 | 2 | throw new \InvalidArgumentException("Value of key [{$key}] is not numeric"); |
|
| 13 | } |
||
| 14 | |||
| 15 | 2 | if (!$value) { |
|
| 16 | 2 | $value = 0; |
|
| 17 | } |
||
| 18 | |||
| 19 | 2 | return $this->setAttribute($key, $value + $amount); |
|
| 20 | } |
||
| 37 |