| 1 | <?php |
||
| 10 | class CommentMinifier implements MinifierInterface |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * Replace remaining comments. |
||
| 14 | * |
||
| 15 | * @param \ArjanSchouten\HtmlMinifier\MinifyContext $context |
||
| 16 | * |
||
| 17 | * @return \ArjanSchouten\HtmlMinifier\MinifyContext |
||
| 18 | */ |
||
| 19 | 5 | public function process(MinifyContext $context) |
|
| 20 | { |
||
| 21 | 5 | return $context->setContents(preg_replace_callback( |
|
| 22 | 5 | '/ |
|
| 23 | <! # search for the start of a comment |
||
| 24 | [^>]* # search for everything without a ">" |
||
| 25 | > # match the end of the comment |
||
| 26 | 5 | /xs', function ($match) { |
|
| 27 | 2 | if (Str::contains(strtolower($match[0]), 'doctype')) { |
|
| 28 | 1 | return $match[0]; |
|
| 29 | } |
||
| 30 | |||
| 31 | 2 | return ''; |
|
| 32 | 5 | }, $context->getContents())); |
|
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Indicates if minification rules depends on command options. |
||
| 37 | * |
||
| 38 | * @return string |
||
| 39 | */ |
||
| 40 | 3 | public function provides() |
|
| 44 | } |
||
| 45 |