Esempio n. 1
0
 public function combineScriptsAndMangle(array $scripts)
 {
     $jsData = join(' ', array_map(function ($script) {
         return file_get_contents($script);
     }, $scripts));
     return $this->jsSqueeze->squeeze($jsData);
 }
Esempio n. 2
0
 /**
  * Apply JSqueeze to $content.
  *
  * @param string $filename target filename
  * @param string $content Content to filter.
  * @throws \Exception
  * @return string
  */
 public function output($filename, $content)
 {
     if (!class_exists('Patchwork\\JSqueeze')) {
         throw new \Exception(sprintf('Cannot not load filter class "%s".', 'Patchwork\\JSqueeze'));
     }
     $jz = new JSqueeze();
     return $jz->squeeze($content, $this->_settings['singleLine'], $this->_settings['keepImportantComments'], $this->_settings['specialVarRx']);
 }
Esempio n. 3
0
 /** @dataProvider provideJs */
 function testJs($file)
 {
     $xfail = '.xfail' === substr($file, -6) ? '.xfail' : '';
     if ($xfail) {
         $file = substr($file, 0, -6);
     }
     if ('.js' === substr($file, -3) && file_exists(__DIR__ . '/expected/' . $file)) {
         $test = file_get_contents(__DIR__ . '/test/' . $file . $xfail);
         $expe = file_get_contents(__DIR__ . '/expected/' . $file);
         $jz = new JSqueeze();
         $test = $jz->squeeze($test) . "\n";
         $xfail ? $this->assertFalse($expe === $test, "Xfail {$file}") : $this->assertSame($expe, $test, "Testing {$file}");
     }
 }
 /**
  * {@inheritdoc}
  */
 public function processSource($contents, FileSource $source)
 {
     $minifier = new JSqueeze();
     return $minifier->squeeze($contents, true, true, JSqueeze::SPECIAL_VAR_PACKER);
 }