@@ -146,6 +146,9 @@ |
||
| 146 | 146 | $this->table(['Minification strategy', 'Size (KB)', 'Saved (KB)', 'Size (%)'], $rows); |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | + /** |
|
| 150 | + * @param integer $new |
|
| 151 | + */ |
|
| 149 | 152 | private function calculateImprovementPercentage($new, $old) |
| 150 | 153 | { |
| 151 | 154 | return ($new - $old) / $old * 100; |
@@ -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, |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | /** |
| 18 | 18 | * Get all the steps which are measured. |
| 19 | 19 | * |
| 20 | - * @return array |
|
| 20 | + * @return ReferencePoint[] |
|
| 21 | 21 | */ |
| 22 | 22 | public function getReferencePoints(); |
| 23 | 23 | } |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | - * @return float |
|
| 40 | + * @return integer |
|
| 41 | 41 | */ |
| 42 | 42 | public function getKiloBytes() |
| 43 | 43 | { |
@@ -78,6 +78,9 @@ |
||
| 78 | 78 | $this->measurement->createReferencePoint($this->calculateInputLength($input), $keyName); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | + /** |
|
| 82 | + * @param string $input |
|
| 83 | + */ |
|
| 81 | 84 | private function calculateInputLength($input) |
| 82 | 85 | { |
| 83 | 86 | return mb_strlen($input, '8bit') + $this->placeholderContainer->getOriginalSize() - $this->placeholderContainer->getPlaceholderSize(); |
@@ -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 | |