Completed
Push — master ( 2ccc3e...bf7d5b )
by Lars
03:43
created
src/CssToInlineStyles.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
   public function setHTML($html)
145 145
   {
146 146
     // strip style definitions, if we use css-class "cleanup" on a style-element
147
-    $this->html = (string)preg_replace('/<style[^>]+class="cleanup"[^>]*>.*<\/style>/Usi', ' ', $html);
147
+    $this->html = (string) preg_replace('/<style[^>]+class="cleanup"[^>]*>.*<\/style>/Usi', ' ', $html);
148 148
   }
149 149
 
150 150
   /**
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
    */
155 155
   public function setCSS($css)
156 156
   {
157
-    $this->css = (string)$css;
157
+    $this->css = (string) $css;
158 158
   }
159 159
 
160 160
   /**
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
   public function convert($outputXHTML = false, $libXMLOptions = 0, $path = false)
196 196
   {
197 197
     // redefine
198
-    $outputXHTML = (bool)$outputXHTML;
198
+    $outputXHTML = (bool) $outputXHTML;
199 199
 
200 200
     // validate
201 201
     if (!$this->html) {
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
       foreach ($document->getElementsByTagName('link') as $node) {
214 214
 
215 215
         /** @noinspection PhpUndefinedMethodInspection */
216
-        $file = ($path ?: __DIR__) . '/' . $node->getAttribute('href');
216
+        $file = ($path ?: __DIR__).'/'.$node->getAttribute('href');
217 217
 
218 218
         if (file_exists($file)) {
219 219
           $css .= file_get_contents($file);
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
     }
265 265
 
266 266
     // just regular HTML 4.01 as it should be used in newsletters
267
-    $html =  $document->saveHTML();
267
+    $html = $document->saveHTML();
268 268
     $html = $this->putReplacedAmperstampBackToPreserveHtmlEntities($html);
269 269
 
270 270
     return $html;
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
     if (!empty($matches[2])) {
291 291
       // add
292 292
       foreach ($matches[2] as $match) {
293
-        $css .= trim($match) . "\n";
293
+        $css .= trim($match)."\n";
294 294
       }
295 295
     }
296 296
 
@@ -310,12 +310,12 @@  discard block
 block discarded – undo
310 310
     $cssRules = array();
311 311
 
312 312
     // init vars
313
-    $css = (string)$css;
313
+    $css = (string) $css;
314 314
 
315 315
     $css = $this->doCleanup($css);
316 316
 
317 317
     // rules are splitted by }
318
-    $rules = (array)explode('}', $css);
318
+    $rules = (array) explode('}', $css);
319 319
 
320 320
     // init var
321 321
     $i = 1;
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
       $cssProperties = trim($chunks[1]);
338 338
 
339 339
       // split multiple selectors
340
-      $selectors = (array)explode(',', $selectors);
340
+      $selectors = (array) explode(',', $selectors);
341 341
 
342 342
       // loop selectors
343 343
       foreach ($selectors as $selector) {
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
       $css = $this->stripeMediaQueries($css);
407 407
     }
408 408
 
409
-    return (string)$css;
409
+    return (string) $css;
410 410
   }
411 411
 
412 412
   /**
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
     // remove comments previously to matching media queries
422 422
     $css = preg_replace(self::$styleCommentRegEx, '', $css);
423 423
 
424
-    return (string)preg_replace(self::$cssMediaQueriesRegEx, '', $css);
424
+    return (string) preg_replace(self::$cssMediaQueriesRegEx, '', $css);
425 425
   }
426 426
 
427 427
   /**
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
    */
434 434
   private function stripeCharsetInCss($css)
435 435
   {
436
-    return (string)preg_replace(self::$cssCharsetRegEx, '', $css);
436
+    return (string) preg_replace(self::$cssCharsetRegEx, '', $css);
437 437
   }
438 438
 
439 439
   /**
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
     // loop properties
455 455
     foreach ($properties as $property) {
456 456
       // split into chunks
457
-      $chunks = (array)explode(':', $property, 2);
457
+      $chunks = (array) explode(':', $property, 2);
458 458
 
459 459
       // validate
460 460
       if (!isset($chunks[1])) {
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
    */
493 493
   private function splitIntoProperties($styles)
494 494
   {
495
-    $properties = (array)explode(';', $styles);
495
+    $properties = (array) explode(';', $styles);
496 496
     $propertiesCount = count($properties);
497 497
 
498 498
     /** @noinspection ForeachInvariantsInspection */
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
           &&
505 505
           strpos($properties[$i + 1], 'base64,') !== false
506 506
       ) {
507
-        $properties[$i] .= ';' . $properties[$i + 1];
507
+        $properties[$i] .= ';'.$properties[$i + 1];
508 508
         $properties[$i + 1] = '';
509 509
         ++$i;
510 510
       }
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
     $xmlHackUsed = false;
541 541
     if (stripos('<?xml', $html) !== 0) {
542 542
       $xmlHackUsed = true;
543
-      $html = '<?xml encoding="' . $this->getEncoding() . '" ?>' . $html;
543
+      $html = '<?xml encoding="'.$this->getEncoding().'" ?>'.$html;
544 544
     }
545 545
 
546 546
     // load HTML
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
     if (null !== $stylesAttribute) {
700 700
       // get value for the styles attribute
701 701
       /** @noinspection PhpUndefinedFieldInspection */
702
-      $definedStyles = (string)$stylesAttribute->value;
702
+      $definedStyles = (string) $stylesAttribute->value;
703 703
 
704 704
       // split into properties
705 705
       $definedProperties = $this->splitIntoProperties($definedStyles);
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
           ||
717 717
           false === stripos($properties[$key], '!important')
718 718
           ||
719
-          false !== stripos(implode('', (array)$value), '!important')
719
+          false !== stripos(implode('', (array) $value), '!important')
720 720
       ) {
721 721
         $properties[$key] = $value;
722 722
       }
@@ -727,8 +727,8 @@  discard block
 block discarded – undo
727 727
 
728 728
     // build chunks
729 729
     foreach ($properties as $key => $values) {
730
-      foreach ((array)$values as $value) {
731
-        $propertyChunks[] = $key . ': ' . $value . ';';
730
+      foreach ((array) $values as $value) {
731
+        $propertyChunks[] = $key.': '.$value.';';
732 732
       }
733 733
     }
734 734
 
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
       }
758 758
 
759 759
       // split into chunks
760
-      $chunks = (array)explode(':', trim($property), 2);
760
+      $chunks = (array) explode(':', trim($property), 2);
761 761
 
762 762
       // validate
763 763
       if (!isset($chunks[1])) {
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
    */
824 824
   public function setCleanup($on = true)
825 825
   {
826
-    $this->cleanup = (bool)$on;
826
+    $this->cleanup = (bool) $on;
827 827
   }
828 828
 
829 829
   /**
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
    */
836 836
   public function setEncoding($encoding)
837 837
   {
838
-    $this->encoding = (string)$encoding;
838
+    $this->encoding = (string) $encoding;
839 839
   }
840 840
 
841 841
   /**
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
    */
847 847
   public function setUseInlineStylesBlock($on = true)
848 848
   {
849
-    $this->useInlineStylesBlock = (bool)$on;
849
+    $this->useInlineStylesBlock = (bool) $on;
850 850
   }
851 851
 
852 852
   /**
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
    */
860 860
   public function setLoadCSSFromHTML($on = true)
861 861
   {
862
-    $this->loadCSSFromHTML = (bool)$on;
862
+    $this->loadCSSFromHTML = (bool) $on;
863 863
   }
864 864
 
865 865
   /**
@@ -870,7 +870,7 @@  discard block
 block discarded – undo
870 870
    */
871 871
   public function setStripOriginalStyleTags($on = true)
872 872
   {
873
-    $this->stripOriginalStyleTags = (bool)$on;
873
+    $this->stripOriginalStyleTags = (bool) $on;
874 874
   }
875 875
 
876 876
   /**
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
    */
885 885
   public function setExcludeMediaQueries($on = true)
886 886
   {
887
-    $this->excludeMediaQueries = (bool)$on;
887
+    $this->excludeMediaQueries = (bool) $on;
888 888
   }
889 889
 
890 890
   /**
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
    */
895 895
   public function setExcludeCssCharset($on = true)
896 896
   {
897
-    $this->excludeCssCharset = (bool)$on;
897
+    $this->excludeCssCharset = (bool) $on;
898 898
   }
899 899
 
900 900
   /**
@@ -904,7 +904,7 @@  discard block
 block discarded – undo
904 904
    */
905 905
   public function setExcludeConditionalInlineStylesBlock($on = true)
906 906
   {
907
-    $this->excludeConditionalInlineStylesBlock = (bool)$on;
907
+    $this->excludeConditionalInlineStylesBlock = (bool) $on;
908 908
   }
909 909
 
910 910
   /**
Please login to merge, or discard this patch.