@@ -1,15 +1,15 @@  | 
                                                    ||
| 1 | 1 | <?php  | 
                                                        
| 2 | 2 | |
| 3 | 3 | require_once 'config.php';  | 
                                                        
| 4 | -require_once __DIR__ . '/../vendor/autoload.php';  | 
                                                        |
| 4 | +require_once __DIR__.'/../vendor/autoload.php';  | 
                                                        |
| 5 | 5 | |
| 6 | 6 | use voku\CssToInlineStyles\CssToInlineStyles;  | 
                                                        
| 7 | 7 | |
| 8 | 8 | // create instance  | 
                                                        
| 9 | 9 | $cssToInlineStyles = new CssToInlineStyles();  | 
                                                        
| 10 | 10 | |
| 11 | -$html = file_get_contents(__DIR__ . '/examples/sumo/index.htm');  | 
                                                        |
| 12 | -$css = file_get_contents(__DIR__ . '/examples/sumo/style.css');  | 
                                                        |
| 11 | +$html = file_get_contents(__DIR__.'/examples/sumo/index.htm');  | 
                                                        |
| 12 | +$css = file_get_contents(__DIR__.'/examples/sumo/style.css');  | 
                                                        |
| 13 | 13 | |
| 14 | 14 | $cssToInlineStyles->setHTML($html);  | 
                                                        
| 15 | 15 | $cssToInlineStyles->setCSS($css);  | 
                                                        
@@ -163,7 +163,7 @@ discard block  | 
                                                    ||
| 163 | 163 | public function setHTML($html)  | 
                                                        
| 164 | 164 |    { | 
                                                        
| 165 | 165 | // strip style definitions, if we use css-class "cleanup" on a style-element  | 
                                                        
| 166 | - $this->html = (string)preg_replace(self::$styleTagWithCleanupClassRegEx, ' ', $html);  | 
                                                        |
| 166 | + $this->html = (string) preg_replace(self::$styleTagWithCleanupClassRegEx, ' ', $html);  | 
                                                        |
| 167 | 167 | |
| 168 | 168 | return $this;  | 
                                                        
| 169 | 169 | }  | 
                                                        
@@ -177,7 +177,7 @@ discard block  | 
                                                    ||
| 177 | 177 | */  | 
                                                        
| 178 | 178 | public function setCSS($css)  | 
                                                        
| 179 | 179 |    { | 
                                                        
| 180 | - $this->css = (string)$css;  | 
                                                        |
| 180 | + $this->css = (string) $css;  | 
                                                        |
| 181 | 181 | |
| 182 | 182 | return $this;  | 
                                                        
| 183 | 183 | }  | 
                                                        
@@ -220,7 +220,7 @@ discard block  | 
                                                    ||
| 220 | 220 | public function convert($outputXHTML = false, $libXMLOptions = 0, $path = false)  | 
                                                        
| 221 | 221 |    { | 
                                                        
| 222 | 222 | // init  | 
                                                        
| 223 | - $outputXHTML = (bool)$outputXHTML;  | 
                                                        |
| 223 | + $outputXHTML = (bool) $outputXHTML;  | 
                                                        |
| 224 | 224 | |
| 225 | 225 | // validate  | 
                                                        
| 226 | 226 |      if (!$this->html) { | 
                                                        
@@ -237,7 +237,7 @@ discard block  | 
                                                    ||
| 237 | 237 |      if ($this->loadCSSFromHTML) { | 
                                                        
| 238 | 238 |        foreach ($dom->find('link') as $node) { | 
                                                        
| 239 | 239 | |
| 240 | -        $file = ($path ?: __DIR__) . '/' . $node->getAttribute('href'); | 
                                                        |
| 240 | +        $file = ($path ?: __DIR__).'/'.$node->getAttribute('href'); | 
                                                        |
| 241 | 241 | |
| 242 | 242 |          if (file_exists($file)) { | 
                                                        
| 243 | 243 | $css .= file_get_contents($file);  | 
                                                        
@@ -303,7 +303,7 @@ discard block  | 
                                                    ||
| 303 | 303 |      if (!empty($matches[1])) { | 
                                                        
| 304 | 304 | // add  | 
                                                        
| 305 | 305 |        foreach ($matches[1] as $match) { | 
                                                        
| 306 | - $css .= trim($match) . "\n";  | 
                                                        |
| 306 | + $css .= trim($match)."\n";  | 
                                                        |
| 307 | 307 | }  | 
                                                        
| 308 | 308 | }  | 
                                                        
| 309 | 309 | |
@@ -323,12 +323,12 @@ discard block  | 
                                                    ||
| 323 | 323 | $cssRules = array();  | 
                                                        
| 324 | 324 | |
| 325 | 325 | // init vars  | 
                                                        
| 326 | - $css = (string)$css;  | 
                                                        |
| 326 | + $css = (string) $css;  | 
                                                        |
| 327 | 327 | |
| 328 | 328 | $css = $this->doCleanup($css);  | 
                                                        
| 329 | 329 | |
| 330 | 330 | // rules are splitted by }  | 
                                                        
| 331 | -    $rules = (array)explode('}', $css); | 
                                                        |
| 331 | +    $rules = (array) explode('}', $css); | 
                                                        |
| 332 | 332 | |
| 333 | 333 | // init var  | 
                                                        
| 334 | 334 | $i = 1;  | 
                                                        
@@ -350,7 +350,7 @@ discard block  | 
                                                    ||
| 350 | 350 | $cssProperties = trim($chunks[1]);  | 
                                                        
| 351 | 351 | |
| 352 | 352 | // split multiple selectors  | 
                                                        
| 353 | -      $selectors = (array)explode(',', $selectors); | 
                                                        |
| 353 | +      $selectors = (array) explode(',', $selectors); | 
                                                        |
| 354 | 354 | |
| 355 | 355 | // loop selectors  | 
                                                        
| 356 | 356 |        foreach ($selectors as $selector) { | 
                                                        
@@ -419,7 +419,7 @@ discard block  | 
                                                    ||
| 419 | 419 | $css = $this->stripeMediaQueries($css);  | 
                                                        
| 420 | 420 | }  | 
                                                        
| 421 | 421 | |
| 422 | - return (string)$css;  | 
                                                        |
| 422 | + return (string) $css;  | 
                                                        |
| 423 | 423 | }  | 
                                                        
| 424 | 424 | |
| 425 | 425 | /**  | 
                                                        
@@ -434,7 +434,7 @@ discard block  | 
                                                    ||
| 434 | 434 | // remove comments previously to matching media queries  | 
                                                        
| 435 | 435 | $css = preg_replace(self::$styleCommentRegEx, '', $css);  | 
                                                        
| 436 | 436 | |
| 437 | - return (string)preg_replace(self::$cssMediaQueriesRegEx, '', $css);  | 
                                                        |
| 437 | + return (string) preg_replace(self::$cssMediaQueriesRegEx, '', $css);  | 
                                                        |
| 438 | 438 | }  | 
                                                        
| 439 | 439 | |
| 440 | 440 | /**  | 
                                                        
@@ -446,7 +446,7 @@ discard block  | 
                                                    ||
| 446 | 446 | */  | 
                                                        
| 447 | 447 | private function stripeCharsetInCss($css)  | 
                                                        
| 448 | 448 |    { | 
                                                        
| 449 | - return (string)preg_replace(self::$cssCharsetRegEx, '', $css);  | 
                                                        |
| 449 | + return (string) preg_replace(self::$cssCharsetRegEx, '', $css);  | 
                                                        |
| 450 | 450 | }  | 
                                                        
| 451 | 451 | |
| 452 | 452 | /**  | 
                                                        
@@ -467,7 +467,7 @@ discard block  | 
                                                    ||
| 467 | 467 | // loop properties  | 
                                                        
| 468 | 468 |      foreach ($properties as $property) { | 
                                                        
| 469 | 469 | // split into chunks  | 
                                                        
| 470 | -      $chunks = (array)explode(':', $property, 2); | 
                                                        |
| 470 | +      $chunks = (array) explode(':', $property, 2); | 
                                                        |
| 471 | 471 | |
| 472 | 472 | // validate  | 
                                                        
| 473 | 473 |        if (!isset($chunks[1])) { | 
                                                        
@@ -505,7 +505,7 @@ discard block  | 
                                                    ||
| 505 | 505 | */  | 
                                                        
| 506 | 506 | private function splitIntoProperties($styles)  | 
                                                        
| 507 | 507 |    { | 
                                                        
| 508 | -    $properties = (array)explode(';', $styles); | 
                                                        |
| 508 | +    $properties = (array) explode(';', $styles); | 
                                                        |
| 509 | 509 | $propertiesCount = count($properties);  | 
                                                        
| 510 | 510 | |
| 511 | 511 | /** @noinspection ForeachInvariantsInspection */  | 
                                                        
@@ -517,7 +517,7 @@ discard block  | 
                                                    ||
| 517 | 517 | &&  | 
                                                        
| 518 | 518 | strpos($properties[$i + 1], 'base64,') !== false  | 
                                                        
| 519 | 519 |        ) { | 
                                                        
| 520 | - $properties[$i] .= ';' . $properties[$i + 1];  | 
                                                        |
| 520 | + $properties[$i] .= ';'.$properties[$i + 1];  | 
                                                        |
| 521 | 521 | $properties[$i + 1] = '';  | 
                                                        
| 522 | 522 | ++$i;  | 
                                                        
| 523 | 523 | }  | 
                                                        
@@ -664,7 +664,7 @@ discard block  | 
                                                    ||
| 664 | 664 | // any styles defined before?  | 
                                                        
| 665 | 665 |      if (null !== $stylesAttribute) { | 
                                                        
| 666 | 666 | // get value for the styles attribute  | 
                                                        
| 667 | - $definedStyles = (string)$stylesAttribute->value;  | 
                                                        |
| 667 | + $definedStyles = (string) $stylesAttribute->value;  | 
                                                        |
| 668 | 668 | |
| 669 | 669 | // split into properties  | 
                                                        
| 670 | 670 | $definedProperties = $this->splitIntoProperties($definedStyles);  | 
                                                        
@@ -681,7 +681,7 @@ discard block  | 
                                                    ||
| 681 | 681 | ||  | 
                                                        
| 682 | 682 | false === stripos($properties[$key], '!important')  | 
                                                        
| 683 | 683 | ||  | 
                                                        
| 684 | -          false !== stripos(implode('', (array)$value), '!important') | 
                                                        |
| 684 | +          false !== stripos(implode('', (array) $value), '!important') | 
                                                        |
| 685 | 685 |        ) { | 
                                                        
| 686 | 686 | $properties[$key] = $value;  | 
                                                        
| 687 | 687 | }  | 
                                                        
@@ -692,8 +692,8 @@ discard block  | 
                                                    ||
| 692 | 692 | |
| 693 | 693 | // build chunks  | 
                                                        
| 694 | 694 |      foreach ($properties as $key => $values) { | 
                                                        
| 695 | -      foreach ((array)$values as $value) { | 
                                                        |
| 696 | - $propertyChunks[] = $key . ': ' . $value . ';';  | 
                                                        |
| 695 | +      foreach ((array) $values as $value) { | 
                                                        |
| 696 | + $propertyChunks[] = $key.': '.$value.';';  | 
                                                        |
| 697 | 697 | }  | 
                                                        
| 698 | 698 | }  | 
                                                        
| 699 | 699 | |
@@ -722,7 +722,7 @@ discard block  | 
                                                    ||
| 722 | 722 | }  | 
                                                        
| 723 | 723 | |
| 724 | 724 | // split into chunks  | 
                                                        
| 725 | -      $chunks = (array)explode(':', trim($property), 2); | 
                                                        |
| 725 | +      $chunks = (array) explode(':', trim($property), 2); | 
                                                        |
| 726 | 726 | |
| 727 | 727 | // validate  | 
                                                        
| 728 | 728 |        if (!isset($chunks[1])) { | 
                                                        
@@ -786,7 +786,7 @@ discard block  | 
                                                    ||
| 786 | 786 | */  | 
                                                        
| 787 | 787 | public function setCleanup($on = true)  | 
                                                        
| 788 | 788 |    { | 
                                                        
| 789 | - $this->cleanup = (bool)$on;  | 
                                                        |
| 789 | + $this->cleanup = (bool) $on;  | 
                                                        |
| 790 | 790 | |
| 791 | 791 | return $this;  | 
                                                        
| 792 | 792 | }  | 
                                                        
@@ -802,7 +802,7 @@ discard block  | 
                                                    ||
| 802 | 802 | */  | 
                                                        
| 803 | 803 | public function setEncoding($encoding)  | 
                                                        
| 804 | 804 |    { | 
                                                        
| 805 | - $this->encoding = (string)$encoding;  | 
                                                        |
| 805 | + $this->encoding = (string) $encoding;  | 
                                                        |
| 806 | 806 | |
| 807 | 807 | return $this;  | 
                                                        
| 808 | 808 | }  | 
                                                        
@@ -818,7 +818,7 @@ discard block  | 
                                                    ||
| 818 | 818 | */  | 
                                                        
| 819 | 819 | public function setUseInlineStylesBlock($on = true)  | 
                                                        
| 820 | 820 |    { | 
                                                        
| 821 | - $this->useInlineStylesBlock = (bool)$on;  | 
                                                        |
| 821 | + $this->useInlineStylesBlock = (bool) $on;  | 
                                                        |
| 822 | 822 | |
| 823 | 823 | return $this;  | 
                                                        
| 824 | 824 | }  | 
                                                        
@@ -834,7 +834,7 @@ discard block  | 
                                                    ||
| 834 | 834 | */  | 
                                                        
| 835 | 835 | public function setLoadCSSFromHTML($on = true)  | 
                                                        
| 836 | 836 |    { | 
                                                        
| 837 | - $this->loadCSSFromHTML = (bool)$on;  | 
                                                        |
| 837 | + $this->loadCSSFromHTML = (bool) $on;  | 
                                                        |
| 838 | 838 | |
| 839 | 839 | return $this;  | 
                                                        
| 840 | 840 | }  | 
                                                        
@@ -850,7 +850,7 @@ discard block  | 
                                                    ||
| 850 | 850 | */  | 
                                                        
| 851 | 851 | public function setStripOriginalStyleTags($on = true)  | 
                                                        
| 852 | 852 |    { | 
                                                        
| 853 | - $this->stripOriginalStyleTags = (bool)$on;  | 
                                                        |
| 853 | + $this->stripOriginalStyleTags = (bool) $on;  | 
                                                        |
| 854 | 854 | |
| 855 | 855 | return $this;  | 
                                                        
| 856 | 856 | }  | 
                                                        
@@ -868,7 +868,7 @@ discard block  | 
                                                    ||
| 868 | 868 | */  | 
                                                        
| 869 | 869 | public function setExcludeMediaQueries($on = true)  | 
                                                        
| 870 | 870 |    { | 
                                                        
| 871 | - $this->excludeMediaQueries = (bool)$on;  | 
                                                        |
| 871 | + $this->excludeMediaQueries = (bool) $on;  | 
                                                        |
| 872 | 872 | |
| 873 | 873 | return $this;  | 
                                                        
| 874 | 874 | }  | 
                                                        
@@ -882,7 +882,7 @@ discard block  | 
                                                    ||
| 882 | 882 | */  | 
                                                        
| 883 | 883 | public function setExcludeCssCharset($on = true)  | 
                                                        
| 884 | 884 |    { | 
                                                        
| 885 | - $this->excludeCssCharset = (bool)$on;  | 
                                                        |
| 885 | + $this->excludeCssCharset = (bool) $on;  | 
                                                        |
| 886 | 886 | |
| 887 | 887 | return $this;  | 
                                                        
| 888 | 888 | }  | 
                                                        
@@ -898,7 +898,7 @@ discard block  | 
                                                    ||
| 898 | 898 | */  | 
                                                        
| 899 | 899 | public function setExcludeConditionalInlineStylesBlock($on = true)  | 
                                                        
| 900 | 900 |    { | 
                                                        
| 901 | - $this->excludeConditionalInlineStylesBlock = (bool)$on;  | 
                                                        |
| 901 | + $this->excludeConditionalInlineStylesBlock = (bool) $on;  | 
                                                        |
| 902 | 902 | |
| 903 | 903 | return $this;  | 
                                                        
| 904 | 904 | }  |