@@ -130,46 +130,13 @@ protected function getFormattedTextBlock(DOMNode $node)
130
130
}
131
131
132
132
$ text = trim ($ text );
133
- $ text = str_replace ('<em> ' , '* ' , $ text );
134
- $ text = str_replace ('</em> ' , '* ' , $ text );
133
+ $ text = str_replace (['<em> ' , '</em> ' ], '* ' , $ text );
135
134
136
135
$ nodeLines = explode ("\n" , $ text );
137
- $ lines = [];
138
-
139
- foreach ($ nodeLines as $ currentLine ) {
140
- $ currentLine = trim ($ currentLine );
141
- if ($ currentLine === '' ) {
142
- // The text contained a blank line. Respect this.
143
- $ lines [] = '' ;
144
- continue ;
145
- }
146
-
147
- $ tempLine = '' ;
148
- $ words = explode (' ' , $ currentLine );
149
-
150
- foreach ($ words as $ word ) {
151
- $ currentLength = strlen ($ tempLine .$ word );
152
- if ($ currentLength < 99 ) {
153
- $ tempLine .= $ word .' ' ;
154
- continue ;
155
- }
156
-
157
- if ($ currentLength === 99 || $ currentLength === 100 ) {
158
- // We are already at the edge, so we are done.
159
- $ lines [] = $ tempLine .$ word ;
160
- $ tempLine = '' ;
161
- } else {
162
- $ lines [] = rtrim ($ tempLine );
163
- $ tempLine = $ word .' ' ;
164
- }
165
- }//end foreach
166
-
167
- if ($ tempLine !== '' ) {
168
- $ lines [] = rtrim ($ tempLine );
169
- }
170
- }//end foreach
136
+ $ nodeLines = array_map ('trim ' , $ nodeLines );
137
+ $ text = implode (PHP_EOL , $ nodeLines );
171
138
172
- return implode ( PHP_EOL , $ lines ).PHP_EOL .PHP_EOL ;
139
+ return wordwrap ( $ text , 100 , PHP_EOL ).PHP_EOL .PHP_EOL ;
173
140
174
141
}//end getFormattedTextBlock()
175
142
@@ -243,8 +210,7 @@ protected function getFormattedCodeComparisonBlock(DOMNode $node)
243
210
$ firstTitleLines [] = $ tempTitle ;
244
211
}
245
212
246
- $ first = str_replace ('<em> ' , '' , $ first );
247
- $ first = str_replace ('</em> ' , '' , $ first );
213
+ $ first = str_replace (['<em> ' , '</em> ' ], '' , $ first );
248
214
$ firstLines = explode ("\n" , $ first );
249
215
250
216
$ second = trim ($ secondCodeElm ->nodeValue );
@@ -278,8 +244,7 @@ protected function getFormattedCodeComparisonBlock(DOMNode $node)
278
244
$ secondTitleLines [] = $ tempTitle ;
279
245
}
280
246
281
- $ second = str_replace ('<em> ' , '' , $ second );
282
- $ second = str_replace ('</em> ' , '' , $ second );
247
+ $ second = str_replace (['<em> ' , '</em> ' ], '' , $ second );
283
248
$ secondLines = explode ("\n" , $ second );
284
249
285
250
$ titleRow = '' ;
0 commit comments