| Conditions | 11 |
| Paths | 10 |
| Total Lines | 30 |
| Code Lines | 15 |
| 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 |
||
| 62 | public function toSource( array $types, array $translations = [], array $plugins = [], array $funcs = [] ) |
||
| 63 | { |
||
| 64 | $expr = $this->getExpressions(); |
||
| 65 | |||
| 66 | if( ( $item = reset( $expr ) ) === false ) { |
||
| 67 | return ''; |
||
| 68 | } |
||
| 69 | |||
| 70 | $op = $this->getOperator(); |
||
| 71 | $string = $item->toSource( $types, $translations, $plugins, $funcs ); |
||
| 72 | |||
| 73 | if( $op == '!' && $string !== '' && $string !== null ) { |
||
| 74 | return ' ' . self::$operators[$op] . ' ( ' . $string . ' )'; |
||
| 75 | } |
||
| 76 | |||
| 77 | while( ( $item = next( $expr ) ) !== false ) |
||
| 78 | { |
||
| 79 | $itemstr = $item->toSource( $types, $translations, $plugins, $funcs ); |
||
| 80 | |||
| 81 | if( $itemstr !== '' && $itemstr !== null ) |
||
| 82 | { |
||
| 83 | if( $string !== '' && $string !== null ) { |
||
| 84 | $string .= ' ' . self::$operators[$op] . ' ' . $itemstr; |
||
| 85 | } else { |
||
| 86 | $string = $itemstr; |
||
| 87 | } |
||
| 88 | } |
||
| 89 | } |
||
| 90 | |||
| 91 | return $string ? '( ' . $string . ' )' : ''; |
||
| 92 | } |
||
| 107 |