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 | 28 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 17 |
| CRAP Score | 11 |
| 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 |
||
| 35 | 40 | protected function parseRange($input) |
|
| 36 | { |
||
| 37 | 40 | if (null === $input || '*' == $input || '*.*.*.*' == $input |
|
| 38 | 40 | || '0.0.0.0-255.255.255.255' == $input) { |
|
| 39 | 9 | return; |
|
| 40 | } |
||
| 41 | |||
| 42 | 31 | $range = ['min' => null, 'max' => null, 'mask' => null]; |
|
| 43 | |||
| 44 | 31 | if (false !== mb_strpos($input, '-')) { |
|
| 45 | 9 | list($range['min'], $range['max']) = explode('-', $input); |
|
| 46 | 22 | } elseif (false !== mb_strpos($input, '*')) { |
|
| 47 | 11 | $this->parseRangeUsingWildcards($input, $range); |
|
| 48 | 11 | } elseif (false !== mb_strpos($input, '/')) { |
|
| 49 | 9 | $this->parseRangeUsingCidr($input, $range); |
|
| 50 | } else { |
||
| 51 | 2 | throw new ComponentException('Invalid network range'); |
|
| 52 | } |
||
| 53 | |||
| 54 | 26 | if (!$this->verifyAddress($range['min'])) { |
|
| 55 | 1 | throw new ComponentException('Invalid network range'); |
|
| 56 | } |
||
| 57 | |||
| 58 | 25 | if (isset($range['max']) && !$this->verifyAddress($range['max'])) { |
|
| 59 | 2 | throw new ComponentException('Invalid network range'); |
|
| 60 | } |
||
| 61 | |||
| 62 | 23 | return $range; |
|
| 63 | } |
||
| 142 |