We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 11 |
| Paths | 11 |
| Total Lines | 29 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 17 |
| CRAP Score | 11.0207 |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 33 | 39 | protected function parseRange($input) |
|
| 34 | { |
||
| 35 | 39 | if ($input === null || $input == '*' || $input == '*.*.*.*' |
|
| 36 | 39 | || $input == '0.0.0.0-255.255.255.255') { |
|
| 37 | 9 | return; |
|
| 38 | } |
||
| 39 | |||
| 40 | 30 | $range = ['min' => null, 'max' => null, 'mask' => null]; |
|
| 41 | |||
| 42 | 30 | if (strpos($input, '-') !== false) { |
|
| 43 | 8 | list($range['min'], $range['max']) = explode('-', $input); |
|
| 44 | 30 | } elseif (strpos($input, '*') !== false) { |
|
| 45 | 11 | $this->parseRangeUsingWildcards($input, $range); |
|
| 46 | 22 | } elseif (strpos($input, '/') !== false) { |
|
| 47 | 9 | $this->parseRangeUsingCidr($input, $range); |
|
| 48 | 6 | } else { |
|
| 49 | 2 | throw new ComponentException('Invalid network range'); |
|
| 50 | } |
||
| 51 | |||
| 52 | 25 | if (!$this->verifyAddress($range['min'])) { |
|
| 53 | throw new ComponentException('Invalid network range'); |
||
| 54 | } |
||
| 55 | |||
| 56 | 25 | if (isset($range['max']) && !$this->verifyAddress($range['max'])) { |
|
| 57 | 2 | throw new ComponentException('Invalid network range'); |
|
| 58 | } |
||
| 59 | |||
| 60 | 23 | return $range; |
|
| 61 | } |
||
| 62 | |||
| 140 |