@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | protected function setupCompiler() |
| 54 | 54 | { |
| 55 | - Blade::extend(function ($value, $compiler) { |
|
| 55 | + Blade::extend(function($value, $compiler) { |
|
| 56 | 56 | BladePlaceholder::setBladeTags($this->getBladeTags($compiler)); |
| 57 | 57 | |
| 58 | 58 | $context = new MinifyContext(new PlaceholderContainer()); |
@@ -123,24 +123,24 @@ discard block |
||
| 123 | 123 | $totalBytesSavedPercentage = 0; |
| 124 | 124 | |
| 125 | 125 | $lastReferencePoint = null; |
| 126 | - $rows = $referencePoints->map(function (ReferencePoint $referencePoint) use (&$lastReferencePoint, &$totalBytesSavedPercentage) { |
|
| 126 | + $rows = $referencePoints->map(function(ReferencePoint $referencePoint) use (&$lastReferencePoint, &$totalBytesSavedPercentage) { |
|
| 127 | 127 | $bytesSaved = ''; |
| 128 | 128 | $bytesSavedPercentage = ''; |
| 129 | 129 | if ($lastReferencePoint != null) { |
| 130 | 130 | $bytesSaved = $lastReferencePoint->getKiloBytes() - $referencePoint->getKiloBytes(); |
| 131 | 131 | $totalBytesSavedPercentage += $bytesSavedPercentage = $this->calculateImprovementPercentage($referencePoint->getKiloBytes(), $lastReferencePoint->getKiloBytes()); |
| 132 | - $bytesSavedPercentage = round(abs($bytesSavedPercentage),1).'%'; |
|
| 132 | + $bytesSavedPercentage = round(abs($bytesSavedPercentage), 1).'%'; |
|
| 133 | 133 | } |
| 134 | 134 | $lastReferencePoint = $referencePoint; |
| 135 | 135 | |
| 136 | - return [$referencePoint->getName(), round($referencePoint->getKiloBytes(),1), round($bytesSaved,1), $bytesSavedPercentage]; |
|
| 136 | + return [$referencePoint->getName(), round($referencePoint->getKiloBytes(), 1), round($bytesSaved, 1), $bytesSavedPercentage]; |
|
| 137 | 137 | }); |
| 138 | 138 | |
| 139 | 139 | $rows[] = [ |
| 140 | 140 | 'Total', |
| 141 | - round($referencePoints->last()->getKiloBytes(),1), |
|
| 142 | - abs(round($referencePoints->last()->getKiloBytes() - $referencePoints->first()->getKiloBytes(),1)), |
|
| 143 | - abs(round($totalBytesSavedPercentage,1)).'%' |
|
| 141 | + round($referencePoints->last()->getKiloBytes(), 1), |
|
| 142 | + abs(round($referencePoints->last()->getKiloBytes() - $referencePoints->first()->getKiloBytes(), 1)), |
|
| 143 | + abs(round($totalBytesSavedPercentage, 1)).'%' |
|
| 144 | 144 | ]; |
| 145 | 145 | |
| 146 | 146 | $this->table(['Minification strategy', 'Size (KB)', 'Saved (KB)', 'Size (%)'], $rows); |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | protected function getOptions() |
| 160 | 160 | { |
| 161 | 161 | $options = Collection::make(Options::options()) |
| 162 | - ->map(function (Option $option) { |
|
| 162 | + ->map(function(Option $option) { |
|
| 163 | 163 | return [ |
| 164 | 164 | $option->getName(), |
| 165 | 165 | null, |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | protected function registerBladeMinifier() |
| 36 | 36 | { |
| 37 | - $this->app->singleton('blade.compiler.min', function () { |
|
| 37 | + $this->app->singleton('blade.compiler.min', function() { |
|
| 38 | 38 | return new Minify(); |
| 39 | 39 | }); |
| 40 | 40 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | protected function registerPhpMinifier() |
| 48 | 48 | { |
| 49 | - $this->app->singleton('php.min', function () { |
|
| 49 | + $this->app->singleton('php.min', function() { |
|
| 50 | 50 | return new Minify(); |
| 51 | 51 | }); |
| 52 | 52 | } |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | )* # special part of "unrolling the loop" |
| 49 | 49 | ) # use a the "unrolling the loop" technique to be able to skip escaped quotes like ="\"" |
| 50 | 50 | \1? # match the same quote symbol as matched before |
| 51 | - /x', function ($match) { |
|
| 51 | + /x', function($match) { |
|
| 52 | 52 | return $this->minifyAttribute($match); |
| 53 | 53 | }, $context->getContents())); |
| 54 | 54 | } |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | ([\'"])? # optional to use a quote |
| 32 | 32 | (\1|true|false|([\s>"\'])) # match the boolean attribute name again or true|false |
| 33 | 33 | \2? # match the quote again |
| 34 | - /xi', function ($match) { |
|
| 34 | + /xi', function($match) { |
|
| 35 | 35 | if (isset($match[4])) { |
| 36 | 36 | return ' '.$match[1]; |
| 37 | 37 | } |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | <! # search for the start of a comment |
| 24 | 24 | [^>]* # search for everything without a ">" |
| 25 | 25 | > # match the end of the comment |
| 26 | - /xs', function ($match) { |
|
| 26 | + /xs', function($match) { |
|
| 27 | 27 | if (Str::contains(strtolower($match[0]), 'doctype')) { |
| 28 | 28 | return $match[0]; |
| 29 | 29 | } |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | ["\']? # Match an optional quote |
| 26 | 26 | \s*javascript: # Match the text "javascript:" which should be removed |
| 27 | 27 | /xis', |
| 28 | - function ($match) { |
|
| 28 | + function($match) { |
|
| 29 | 29 | return str_replace('javascript:', '', $match[0]); |
| 30 | 30 | }, $context->getContents()); |
| 31 | 31 | |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public function process(MinifyContext $context) |
| 42 | 42 | { |
| 43 | - Collection::make($this->redundantAttributes)->each(function ($attributes, $element) use (&$context) { |
|
| 44 | - Collection::make($attributes)->each(function ($value, $attribute) use ($element, &$context) { |
|
| 43 | + Collection::make($this->redundantAttributes)->each(function($attributes, $element) use (&$context) { |
|
| 44 | + Collection::make($attributes)->each(function($value, $attribute) use ($element, &$context) { |
|
| 45 | 45 | $contents = preg_replace_callback( |
| 46 | 46 | '/ |
| 47 | 47 | '.$element.' # Match the given element |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | \s* |
| 56 | 56 | ) |
| 57 | 57 | /xis', |
| 58 | - function ($match) { |
|
| 58 | + function($match) { |
|
| 59 | 59 | return $this->removeAttribute($match[0], $match[2]); |
| 60 | 60 | }, $context->getContents()); |
| 61 | 61 | |
@@ -79,21 +79,21 @@ |
||
| 79 | 79 | */ |
| 80 | 80 | protected function removeNestedPlaceholders($originalContent) |
| 81 | 81 | { |
| 82 | - return preg_replace_callback('/'.Constants::PLACEHOLDER_PATTERN.'/', function ($match) { |
|
| 82 | + return preg_replace_callback('/'.Constants::PLACEHOLDER_PATTERN.'/', function($match) { |
|
| 83 | 83 | return $this->get($match[0]); |
| 84 | 84 | }, $originalContent); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | public function getPlaceholderSize() |
| 88 | 88 | { |
| 89 | - return $this->keys()->sum(function ($key) { |
|
| 89 | + return $this->keys()->sum(function($key) { |
|
| 90 | 90 | return mb_strlen($key, '8bit'); |
| 91 | 91 | }); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | public function getOriginalSize() |
| 95 | 95 | { |
| 96 | - return $this->values()->sum(function ($value) { |
|
| 96 | + return $this->values()->sum(function($value) { |
|
| 97 | 97 | return mb_strlen($value, '8bit'); |
| 98 | 98 | }); |
| 99 | 99 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | @? # Match a @ for blades ignore echo |
| 50 | 50 | %s\s*(.+?)\s*%s(\r?\n)? |
| 51 | 51 | /xs', $tag[0], $tag[1]); |
| 52 | - $contents = preg_replace_callback($pattern, function ($match) use ($placeholderContainer) { |
|
| 52 | + $contents = preg_replace_callback($pattern, function($match) use ($placeholderContainer) { |
|
| 53 | 53 | return $placeholderContainer->addPlaceholder($match[0]); |
| 54 | 54 | }, $contents); |
| 55 | 55 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | protected function setBladeControlStructuresPlaceholder($contents, PlaceholderContainer $placeholderContainer) |
| 69 | 69 | { |
| 70 | - return preg_replace_callback('/@\w*(\s*\(.*\))?/', function ($match) use ($placeholderContainer) { |
|
| 70 | + return preg_replace_callback('/@\w*(\s*\(.*\))?/', function($match) use ($placeholderContainer) { |
|
| 71 | 71 | return $placeholderContainer->addPlaceholder($match[0]); |
| 72 | 72 | }, $contents); |
| 73 | 73 | } |