Conditions | 12 |
Paths | 64 |
Total Lines | 36 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
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 |
||
56 | private static function doRemoveAnnotation( array $matches ) { |
||
|
|||
57 | |||
58 | $caption = false; |
||
59 | $value = ''; |
||
60 | |||
61 | // #1453 |
||
62 | if ( $matches[0] === InTextAnnotationParser::OFF || $matches[0] === InTextAnnotationParser::ON ) { |
||
63 | return false; |
||
64 | } |
||
65 | |||
66 | // Strict mode matching |
||
67 | if ( array_key_exists( 1, $matches ) ) { |
||
68 | if ( strpos( $matches[1], ':' ) !== false && isset( $matches[2] ) ) { |
||
69 | list( $matches[1], $matches[2] ) = explode( '::', $matches[1] . '::' . $matches[2], 2 ); |
||
70 | } |
||
71 | } |
||
72 | |||
73 | if ( array_key_exists( 2, $matches ) ) { |
||
74 | |||
75 | // #1747 |
||
76 | if ( strpos( $matches[1], '|' ) !== false ) { |
||
77 | return $matches[0]; |
||
78 | } |
||
79 | |||
80 | $parts = explode( '|', $matches[2] ); |
||
81 | $value = array_key_exists( 0, $parts ) ? $parts[0] : ''; |
||
82 | $caption = array_key_exists( 1, $parts ) ? $parts[1] : false; |
||
83 | } |
||
84 | |||
85 | // #... |
||
86 | if ( $value === '@@@' ) { |
||
87 | $value = ''; |
||
88 | } |
||
89 | |||
90 | return $caption !== false ? $caption : $value; |
||
91 | } |
||
92 | |||
94 |