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 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 11.0245 |
| 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 |
||
| 58 | 45 | protected function parseRange($input) |
|
| 59 | { |
||
| 60 | 45 | if (null === $input || '*' == $input || '*.*.*.*' == $input |
|
| 61 | 45 | || '0.0.0.0-255.255.255.255' == $input) { |
|
| 62 | 13 | return; |
|
| 63 | } |
||
| 64 | |||
| 65 | 33 | $range = ['min' => null, 'max' => null, 'mask' => null]; |
|
| 66 | |||
| 67 | 33 | if (false !== mb_strpos($input, '-')) { |
|
| 68 | 9 | list($range['min'], $range['max']) = explode('-', $input); |
|
| 69 | 24 | } elseif (false !== mb_strpos($input, '*')) { |
|
| 70 | 12 | $this->parseRangeUsingWildcards($input, $range); |
|
| 71 | 12 | } elseif (false !== mb_strpos($input, '/')) { |
|
| 72 | 9 | $this->parseRangeUsingCidr($input, $range); |
|
| 73 | } else { |
||
| 74 | 3 | throw new ComponentException('Invalid network range'); |
|
| 75 | } |
||
| 76 | |||
| 77 | 27 | if (!$this->verifyAddress($range['min'])) { |
|
| 78 | throw new ComponentException('Invalid network range'); |
||
| 79 | } |
||
| 80 | |||
| 81 | 27 | if (isset($range['max']) && !$this->verifyAddress($range['max'])) { |
|
| 82 | 2 | throw new ComponentException('Invalid network range'); |
|
| 83 | } |
||
| 84 | |||
| 85 | 25 | return $range; |
|
| 86 | } |
||
| 165 |