Conditions | 4 |
Paths | 5 |
Total Lines | 16 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 4 |
CRAP Score | 4.128 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
37 | public function valueAdd($key, $value) |
||
38 | { |
||
39 | if (!$this->has($key)) { |
||
|
|||
40 | $this->set($key, $value); |
||
41 | |||
42 | return; |
||
43 | } |
||
44 | 1 | ||
45 | $currentValue = $this->get($key, 0); |
||
46 | 1 | $currentValue = $currentValue === null ? 0 : $currentValue; |
|
47 | |||
48 | 1 | if (!is_numeric($currentValue)) { |
|
49 | throw new Exception("Current value for key {$key} is not numeric. [{$value}] provided. "); |
||
50 | } |
||
51 | |||
52 | 1 | $this->set($key, ($currentValue + $value)); |
|
53 | 1 | } |
|
72 |