/** * Compresses a string. * * @param string $content The content to compress * @param string $type The type of content, either "js" or "css" * @param array $options An indexed array of additional options * * @return string The compressed content */ protected function compress($content, $type, $options = array()) { $pb = new ProcessBuilder(); $pb->add($this->javaPath)->add('-jar')->add($this->jarPath)->add('--type')->add($type); foreach ($options as $option) { $pb->add($option); } if (null !== $this->charset) { $pb->add('--charset')->add($this->charset); } if (null !== $this->lineBreak) { $pb->add('--line-break')->add($this->lineBreak); } $pb->setInput($content); $proc = $pb->getProcess(); $code = $proc->run(); if (0 < $code) { throw new \RuntimeException($proc->getErrorOutput()); } return $proc->getOutput(); }