| Conditions | 6 |
| Paths | 4 |
| Total Lines | 14 |
| Lines | 6 |
| Ratio | 42.86 % |
| Tests | 8 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | 103 | private function validate(string $percentage): void |
|
| 25 | { |
||
| 26 | 103 | if (!is_numeric($percentage)) { |
|
| 27 | 3 | throw new InvalidArgumentException('string is not a valid number'); |
|
| 28 | } |
||
| 29 | |||
| 30 | 100 | View Code Duplication | if (ceil((float) $percentage) >= 100 && floor((float) $percentage) >= 100) { |
| 31 | 4 | throw new InvalidArgumentException('Value to high, must be at most 99.999.'); |
|
| 32 | } |
||
| 33 | |||
| 34 | 96 | View Code Duplication | if (floor((float) $percentage) <= 0 && ceil((float) $percentage) != 1) { |
| 35 | 2 | throw new InvalidArgumentException('Value to low, must be more than 0.'); |
|
| 36 | } |
||
| 37 | 94 | } |
|
| 38 | } |
||
| 39 |