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 |
Code Lines | 18 |
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 |
||
23 | 39 | protected function parseRange($input) |
|
24 | { |
||
25 | 39 | if ($input === null || $input == '*' || $input == '*.*.*.*' |
|
26 | 39 | || $input == '0.0.0.0-255.255.255.255') { |
|
27 | 9 | return; |
|
28 | } |
||
29 | |||
30 | 30 | $range = array('min' => null, 'max' => null, 'mask' => null); |
|
31 | |||
32 | 30 | if (strpos($input, '-') !== false) { |
|
33 | 8 | list($range['min'], $range['max']) = explode('-', $input); |
|
34 | 30 | } elseif (strpos($input, '*') !== false) { |
|
35 | 11 | $this->parseRangeUsingWildcards($input, $range); |
|
36 | 22 | } elseif (strpos($input, '/') !== false) { |
|
37 | 9 | $this->parseRangeUsingCidr($input, $range); |
|
38 | 6 | } else { |
|
39 | 2 | throw new ComponentException('Invalid network range'); |
|
40 | } |
||
41 | |||
42 | 25 | if (!$this->verifyAddress($range['min'])) { |
|
43 | throw new ComponentException('Invalid network range'); |
||
44 | } |
||
45 | |||
46 | 25 | if (isset($range['max']) && !$this->verifyAddress($range['max'])) { |
|
47 | 2 | throw new ComponentException('Invalid network range'); |
|
48 | } |
||
49 | |||
50 | 23 | return $range; |
|
51 | } |
||
52 | |||
130 |