@@ -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); |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | /** |
| 291 | 291 | * Process the loaded CSS |
| 292 | 292 | * |
| 293 | - * @param $css |
|
| 293 | + * @param string $css |
|
| 294 | 294 | * |
| 295 | 295 | * @return array |
| 296 | 296 | */ |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | /** |
| 418 | 418 | * remove charset from the string |
| 419 | 419 | * |
| 420 | - * @param $css |
|
| 420 | + * @param string $css |
|
| 421 | 421 | * |
| 422 | 422 | * @return string |
| 423 | 423 | */ |
@@ -633,7 +633,7 @@ discard block |
||
| 633 | 633 | * @param \DOMElement $element |
| 634 | 634 | * @param array $ruleProperties |
| 635 | 635 | * |
| 636 | - * @return array |
|
| 636 | + * @return string |
|
| 637 | 637 | */ |
| 638 | 638 | private function createPropertyChunks(\DOMElement $element, array $ruleProperties) |
| 639 | 639 | { |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | public function setHTML($html) |
| 146 | 146 | { |
| 147 | 147 | // strip style definitions, if we use css-class "cleanup" on a style-element |
| 148 | - $this->html = (string)preg_replace('/<style[^>]+class="cleanup"[^>]*>.*<\/style>/Usi', ' ', $html); |
|
| 148 | + $this->html = (string) preg_replace('/<style[^>]+class="cleanup"[^>]*>.*<\/style>/Usi', ' ', $html); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | public function setCSS($css) |
| 157 | 157 | { |
| 158 | - $this->css = (string)$css; |
|
| 158 | + $this->css = (string) $css; |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /** |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | public function convert($outputXHTML = false, $libXMLOptions = 0, $path = false) |
| 197 | 197 | { |
| 198 | 198 | // redefine |
| 199 | - $outputXHTML = (bool)$outputXHTML; |
|
| 199 | + $outputXHTML = (bool) $outputXHTML; |
|
| 200 | 200 | |
| 201 | 201 | // validate |
| 202 | 202 | if (!$this->html) { |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | foreach ($dom->find('link') as $node) { |
| 215 | 215 | |
| 216 | 216 | /** @noinspection PhpUndefinedMethodInspection */ |
| 217 | - $file = ($path ?: __DIR__) . '/' . $node->getAttribute('href'); |
|
| 217 | + $file = ($path ?: __DIR__).'/'.$node->getAttribute('href'); |
|
| 218 | 218 | |
| 219 | 219 | if (file_exists($file)) { |
| 220 | 220 | $css .= file_get_contents($file); |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | if (!empty($matches[2])) { |
| 281 | 281 | // add |
| 282 | 282 | foreach ($matches[2] as $match) { |
| 283 | - $css .= trim($match) . "\n"; |
|
| 283 | + $css .= trim($match)."\n"; |
|
| 284 | 284 | } |
| 285 | 285 | } |
| 286 | 286 | |
@@ -300,12 +300,12 @@ discard block |
||
| 300 | 300 | $cssRules = array(); |
| 301 | 301 | |
| 302 | 302 | // init vars |
| 303 | - $css = (string)$css; |
|
| 303 | + $css = (string) $css; |
|
| 304 | 304 | |
| 305 | 305 | $css = $this->doCleanup($css); |
| 306 | 306 | |
| 307 | 307 | // rules are splitted by } |
| 308 | - $rules = (array)explode('}', $css); |
|
| 308 | + $rules = (array) explode('}', $css); |
|
| 309 | 309 | |
| 310 | 310 | // init var |
| 311 | 311 | $i = 1; |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | $cssProperties = trim($chunks[1]); |
| 328 | 328 | |
| 329 | 329 | // split multiple selectors |
| 330 | - $selectors = (array)explode(',', $selectors); |
|
| 330 | + $selectors = (array) explode(',', $selectors); |
|
| 331 | 331 | |
| 332 | 332 | // loop selectors |
| 333 | 333 | foreach ($selectors as $selector) { |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | $css = $this->stripeMediaQueries($css); |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | - return (string)$css; |
|
| 399 | + return (string) $css; |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | /** |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | // remove comments previously to matching media queries |
| 412 | 412 | $css = preg_replace(self::$styleCommentRegEx, '', $css); |
| 413 | 413 | |
| 414 | - return (string)preg_replace(self::$cssMediaQueriesRegEx, '', $css); |
|
| 414 | + return (string) preg_replace(self::$cssMediaQueriesRegEx, '', $css); |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | /** |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | */ |
| 424 | 424 | private function stripeCharsetInCss($css) |
| 425 | 425 | { |
| 426 | - return (string)preg_replace(self::$cssCharsetRegEx, '', $css); |
|
| 426 | + return (string) preg_replace(self::$cssCharsetRegEx, '', $css); |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | /** |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | // loop properties |
| 445 | 445 | foreach ($properties as $property) { |
| 446 | 446 | // split into chunks |
| 447 | - $chunks = (array)explode(':', $property, 2); |
|
| 447 | + $chunks = (array) explode(':', $property, 2); |
|
| 448 | 448 | |
| 449 | 449 | // validate |
| 450 | 450 | if (!isset($chunks[1])) { |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | */ |
| 483 | 483 | private function splitIntoProperties($styles) |
| 484 | 484 | { |
| 485 | - $properties = (array)explode(';', $styles); |
|
| 485 | + $properties = (array) explode(';', $styles); |
|
| 486 | 486 | $propertiesCount = count($properties); |
| 487 | 487 | |
| 488 | 488 | /** @noinspection ForeachInvariantsInspection */ |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | && |
| 495 | 495 | strpos($properties[$i + 1], 'base64,') !== false |
| 496 | 496 | ) { |
| 497 | - $properties[$i] .= ';' . $properties[$i + 1]; |
|
| 497 | + $properties[$i] .= ';'.$properties[$i + 1]; |
|
| 498 | 498 | $properties[$i + 1] = ''; |
| 499 | 499 | ++$i; |
| 500 | 500 | } |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | if (null !== $stylesAttribute) { |
| 648 | 648 | // get value for the styles attribute |
| 649 | 649 | /** @noinspection PhpUndefinedFieldInspection */ |
| 650 | - $definedStyles = (string)$stylesAttribute->value; |
|
| 650 | + $definedStyles = (string) $stylesAttribute->value; |
|
| 651 | 651 | |
| 652 | 652 | // split into properties |
| 653 | 653 | $definedProperties = $this->splitIntoProperties($definedStyles); |
@@ -664,7 +664,7 @@ discard block |
||
| 664 | 664 | || |
| 665 | 665 | false === stripos($properties[$key], '!important') |
| 666 | 666 | || |
| 667 | - false !== stripos(implode('', (array)$value), '!important') |
|
| 667 | + false !== stripos(implode('', (array) $value), '!important') |
|
| 668 | 668 | ) { |
| 669 | 669 | $properties[$key] = $value; |
| 670 | 670 | } |
@@ -675,8 +675,8 @@ discard block |
||
| 675 | 675 | |
| 676 | 676 | // build chunks |
| 677 | 677 | foreach ($properties as $key => $values) { |
| 678 | - foreach ((array)$values as $value) { |
|
| 679 | - $propertyChunks[] = $key . ': ' . $value . ';'; |
|
| 678 | + foreach ((array) $values as $value) { |
|
| 679 | + $propertyChunks[] = $key.': '.$value.';'; |
|
| 680 | 680 | } |
| 681 | 681 | } |
| 682 | 682 | |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | } |
| 706 | 706 | |
| 707 | 707 | // split into chunks |
| 708 | - $chunks = (array)explode(':', trim($property), 2); |
|
| 708 | + $chunks = (array) explode(':', trim($property), 2); |
|
| 709 | 709 | |
| 710 | 710 | // validate |
| 711 | 711 | if (!isset($chunks[1])) { |
@@ -771,7 +771,7 @@ discard block |
||
| 771 | 771 | */ |
| 772 | 772 | public function setCleanup($on = true) |
| 773 | 773 | { |
| 774 | - $this->cleanup = (bool)$on; |
|
| 774 | + $this->cleanup = (bool) $on; |
|
| 775 | 775 | } |
| 776 | 776 | |
| 777 | 777 | /** |
@@ -783,7 +783,7 @@ discard block |
||
| 783 | 783 | */ |
| 784 | 784 | public function setEncoding($encoding) |
| 785 | 785 | { |
| 786 | - $this->encoding = (string)$encoding; |
|
| 786 | + $this->encoding = (string) $encoding; |
|
| 787 | 787 | } |
| 788 | 788 | |
| 789 | 789 | /** |
@@ -794,7 +794,7 @@ discard block |
||
| 794 | 794 | */ |
| 795 | 795 | public function setUseInlineStylesBlock($on = true) |
| 796 | 796 | { |
| 797 | - $this->useInlineStylesBlock = (bool)$on; |
|
| 797 | + $this->useInlineStylesBlock = (bool) $on; |
|
| 798 | 798 | } |
| 799 | 799 | |
| 800 | 800 | /** |
@@ -807,7 +807,7 @@ discard block |
||
| 807 | 807 | */ |
| 808 | 808 | public function setLoadCSSFromHTML($on = true) |
| 809 | 809 | { |
| 810 | - $this->loadCSSFromHTML = (bool)$on; |
|
| 810 | + $this->loadCSSFromHTML = (bool) $on; |
|
| 811 | 811 | } |
| 812 | 812 | |
| 813 | 813 | /** |
@@ -818,7 +818,7 @@ discard block |
||
| 818 | 818 | */ |
| 819 | 819 | public function setStripOriginalStyleTags($on = true) |
| 820 | 820 | { |
| 821 | - $this->stripOriginalStyleTags = (bool)$on; |
|
| 821 | + $this->stripOriginalStyleTags = (bool) $on; |
|
| 822 | 822 | } |
| 823 | 823 | |
| 824 | 824 | /** |
@@ -832,7 +832,7 @@ discard block |
||
| 832 | 832 | */ |
| 833 | 833 | public function setExcludeMediaQueries($on = true) |
| 834 | 834 | { |
| 835 | - $this->excludeMediaQueries = (bool)$on; |
|
| 835 | + $this->excludeMediaQueries = (bool) $on; |
|
| 836 | 836 | } |
| 837 | 837 | |
| 838 | 838 | /** |
@@ -842,7 +842,7 @@ discard block |
||
| 842 | 842 | */ |
| 843 | 843 | public function setExcludeCssCharset($on = true) |
| 844 | 844 | { |
| 845 | - $this->excludeCssCharset = (bool)$on; |
|
| 845 | + $this->excludeCssCharset = (bool) $on; |
|
| 846 | 846 | } |
| 847 | 847 | |
| 848 | 848 | /** |
@@ -852,6 +852,6 @@ discard block |
||
| 852 | 852 | */ |
| 853 | 853 | public function setExcludeConditionalInlineStylesBlock($on = true) |
| 854 | 854 | { |
| 855 | - $this->excludeConditionalInlineStylesBlock = (bool)$on; |
|
| 855 | + $this->excludeConditionalInlineStylesBlock = (bool) $on; |
|
| 856 | 856 | } |
| 857 | 857 | } |