| Conditions | 12 |
| Paths | 54 |
| Total Lines | 37 |
| Code Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | 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 |
||
| 23 | public static function getArgument(array $argv = null) |
||
| 24 | { |
||
| 25 | if (null === $argv) { |
||
| 26 | $argv = isset($GLOBALS['argv']) ? $GLOBALS['argv'] : array(); |
||
| 27 | } |
||
| 28 | |||
| 29 | $args = $argv; |
||
| 30 | $utility = array_shift($args); |
||
| 31 | unset($utility); |
||
| 32 | |||
| 33 | while ($option = array_shift($args)) { |
||
| 34 | if ('--' === $option) { |
||
| 35 | break; |
||
| 36 | } |
||
| 37 | $len = strlen($option); |
||
| 38 | if (!$len) { |
||
| 39 | continue; |
||
| 40 | } |
||
| 41 | if ('-' !== $option[0]) { |
||
| 42 | continue; |
||
| 43 | } |
||
| 44 | if ('--root-dir' === $option) { |
||
| 45 | if (null !== $argument = array_shift($args)) { |
||
| 46 | $path = $argument; |
||
| 47 | break; |
||
| 48 | } |
||
| 49 | } |
||
| 50 | if ('--root-dir=' === substr($option, 0, 11)) { |
||
| 51 | if ($len > 11) { |
||
| 52 | $path = substr($option, 11); |
||
| 53 | } |
||
| 54 | break; |
||
| 55 | } |
||
| 56 | } |
||
| 57 | |||
| 58 | return isset($path) ? $path : null; |
||
| 59 | } |
||
| 60 | } |
||
| 61 |
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.