| Conditions | 10 |
| Paths | 14 |
| Total Lines | 36 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 81 | public function getLongOptionArgument($name) |
||
| 82 | { |
||
| 83 | $long = "--$name"; |
||
| 84 | |||
| 85 | $args = $this->argv; |
||
| 86 | |||
| 87 | // utility |
||
| 88 | array_shift($args); |
||
| 89 | |||
| 90 | while ($option = array_shift($args)) { |
||
| 91 | if ('--' === $option) { |
||
| 92 | break; |
||
| 93 | } |
||
| 94 | $len = strlen($option); |
||
| 95 | if (!$len) { |
||
| 96 | continue; |
||
| 97 | } |
||
| 98 | if ('-' !== $option[0]) { |
||
| 99 | continue; |
||
| 100 | } |
||
| 101 | if ($long === $option) { |
||
| 102 | if (null !== $argument = array_shift($args)) { |
||
| 103 | $path = $argument; |
||
| 104 | } |
||
| 105 | break; |
||
| 106 | } |
||
| 107 | if ($long . '=' === substr($option, 0, $optLen = strlen($long) + 1)) { |
||
| 108 | if ($len > $optLen) { |
||
| 109 | $path = substr($option, $optLen); |
||
| 110 | } |
||
| 111 | break; |
||
| 112 | } |
||
| 113 | } |
||
| 114 | |||
| 115 | return isset($path) ? $path : null; |
||
| 116 | } |
||
| 117 | } |
||
| 118 |
This check looks for
@paramannotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.