Completed
Pull Request — master (#25)
by Josh
04:08
created
lib/Caxy/HtmlDiff/AbstractDiff.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -172,13 +172,13 @@  discard block
 block discarded – undo
172 172
 
173 173
     protected function getStringBetween($str, $start, $end)
174 174
     {
175
-        $expStr = explode( $start, $str, 2 );
176
-        if ( count( $expStr ) > 1 ) {
177
-            $expStr = explode( $end, $expStr[ 1 ] );
178
-            if ( count( $expStr ) > 1 ) {
179
-                array_pop( $expStr );
175
+        $expStr = explode($start, $str, 2);
176
+        if (count($expStr) > 1) {
177
+            $expStr = explode($end, $expStr[1]);
178
+            if (count($expStr) > 1) {
179
+                array_pop($expStr);
180 180
 
181
-                return implode( $end, $expStr );
181
+                return implode($end, $expStr);
182 182
             }
183 183
         }
184 184
 
@@ -187,13 +187,13 @@  discard block
 block discarded – undo
187 187
 
188 188
     protected function purifyHtml($html, $tags = null)
189 189
     {
190
-        if ( class_exists( 'Tidy' ) && false ) {
191
-            $config = array( 'output-xhtml'   => true, 'indent' => false );
190
+        if (class_exists('Tidy') && false) {
191
+            $config = array('output-xhtml'   => true, 'indent' => false);
192 192
             $tidy = new tidy();
193
-            $tidy->parseString( $html, $config, 'utf8' );
193
+            $tidy->parseString($html, $config, 'utf8');
194 194
             $html = (string) $tidy;
195 195
 
196
-            return $this->getStringBetween( $html, '<body>' );
196
+            return $this->getStringBetween($html, '<body>');
197 197
         }
198 198
 
199 199
         return $html;
@@ -201,8 +201,8 @@  discard block
 block discarded – undo
201 201
 
202 202
     protected function splitInputsToWords()
203 203
     {
204
-        $this->oldWords = $this->convertHtmlToListOfWords( $this->explode( $this->oldText ) );
205
-        $this->newWords = $this->convertHtmlToListOfWords( $this->explode( $this->newText ) );
204
+        $this->oldWords = $this->convertHtmlToListOfWords($this->explode($this->oldText));
205
+        $this->newWords = $this->convertHtmlToListOfWords($this->explode($this->newText));
206 206
     }
207 207
 
208 208
     protected function isPartOfWord($text)
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
         foreach ($characterString as $i => $character) {
219 219
             switch ($mode) {
220 220
                 case 'character':
221
-                if ( $this->isStartOfTag( $character ) ) {
221
+                if ($this->isStartOfTag($character)) {
222 222
                     if ($current_word != '') {
223 223
                         $words[] = $current_word;
224 224
                     }
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
                 } else {
234 234
                     if (
235 235
                         (ctype_alnum($character) && (strlen($current_word) == 0 || $this->isPartOfWord($current_word))) ||
236
-                        (in_array($character, $this->specialCaseChars) && isset($characterString[$i+1]) && $this->isPartOfWord($characterString[$i+1]))
236
+                        (in_array($character, $this->specialCaseChars) && isset($characterString[$i + 1]) && $this->isPartOfWord($characterString[$i + 1]))
237 237
                     ) {
238 238
                         $current_word .= $character;
239 239
                     } else {
@@ -243,12 +243,12 @@  discard block
 block discarded – undo
243 243
                 }
244 244
                 break;
245 245
                 case 'tag' :
246
-                if ( $this->isEndOfTag( $character ) ) {
246
+                if ($this->isEndOfTag($character)) {
247 247
                     $current_word .= ">";
248 248
                     $words[] = $current_word;
249 249
                     $current_word = "";
250 250
 
251
-                    if ( !preg_match('[^\s]', $character ) ) {
251
+                    if (!preg_match('[^\s]', $character)) {
252 252
                         $mode = 'whitespace';
253 253
                     } else {
254 254
                         $mode = 'character';
@@ -258,13 +258,13 @@  discard block
 block discarded – undo
258 258
                 }
259 259
                 break;
260 260
                 case 'whitespace':
261
-                if ( $this->isStartOfTag( $character ) ) {
261
+                if ($this->isStartOfTag($character)) {
262 262
                     if ($current_word !== '') {
263 263
                         $words[] = $current_word;
264 264
                     }
265 265
                     $current_word = "<";
266 266
                     $mode = 'tag';
267
-                } elseif ( preg_match( "/\s/", $character ) ) {
267
+                } elseif (preg_match("/\s/", $character)) {
268 268
                     $current_word .= $character;
269 269
                     $current_word = preg_replace('/\s+/S', ' ', $current_word);
270 270
                 } else {
@@ -298,12 +298,12 @@  discard block
 block discarded – undo
298 298
 
299 299
     protected function isWhiteSpace($value)
300 300
     {
301
-        return !preg_match( '[^\s]', $value );
301
+        return !preg_match('[^\s]', $value);
302 302
     }
303 303
 
304 304
     protected function explode($value)
305 305
     {
306 306
         // as suggested by @onassar
307
-        return preg_split( '//u', $value );
307
+        return preg_split('//u', $value);
308 308
     }
309 309
 }
Please login to merge, or discard this patch.