Conditions | 3 |
Paths | 2 |
Total Lines | 52 |
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 |
||
90 | function html2plaintext($text, $texthtml0, $wrap) |
||
|
|||
91 | { |
||
92 | global $smiley; |
||
93 | |||
94 | if ($texthtml0) { |
||
95 | $text = str_replace( |
||
96 | [ |
||
97 | '<p>', |
||
98 | "\n", |
||
99 | "\r", |
||
100 | ], |
||
101 | '', |
||
102 | $text |
||
103 | ); |
||
104 | $text = str_replace( |
||
105 | [ |
||
106 | '<br />', |
||
107 | '</p>', |
||
108 | ], |
||
109 | "\n", |
||
110 | $text |
||
111 | ); |
||
112 | $text = html_entity_decode($text, ENT_COMPAT, 'UTF-8'); |
||
113 | } else { |
||
114 | // convert smileys ... |
||
115 | $countSmileyImage = count($smiley['image']); |
||
116 | for ($n = 0; $n < $countSmileyImage; $n++) { |
||
117 | $text = mb_ereg_replace( |
||
118 | '<img [^>]*?src=[^>]+?' . str_replace('.', '\.', $smiley['file'][$n]) . '[^>]+?>', |
||
119 | '[s![' . $smiley['text'][$n] . ']!s]', |
||
120 | $text |
||
121 | ); |
||
122 | // the [s[ ]s] is needed to protect the spaces around the smileys |
||
123 | } |
||
124 | |||
125 | // REDMINE-1249: Missing log text in mail notification |
||
126 | // simpler solution that converts html to text as the previous class html2text emptied the text completely |
||
127 | // implementation for line wrap, url's and probably more is missing |
||
128 | $text = preg_replace( "/\n\s+/", "\n", rtrim(html_entity_decode(strip_tags($text)))); |
||
129 | |||
130 | $text = str_replace( |
||
131 | [ |
||
132 | '[s![', |
||
133 | ']!s]', |
||
134 | ], |
||
135 | '', |
||
136 | $text |
||
137 | ); |
||
138 | } |
||
139 | |||
140 | return $text; |
||
141 | } |
||
142 | |||
151 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.