/** * Compile function. Returns a compile content, or writes it to a file if path is specified. * * @param null|string $file * @return string|true */ public function compile($path = null) { parent::compile(); $file = $this->getMinifiedResource(); $file->rewind(); $scss = new \scssc(); $string = $scss->compile($file->read()); if (null !== $path) { $file2 = new FileObject($path, 'w+'); $file2->write($string); $string = true; } unset($file); unset($file2); return $string; }
/** * Compile function. Returns a compile content, or writes it to a file if path is specified. * * @param null|string $file * @return string|true */ public function compile($path = null) { parent::compile(); $file = $this->getMinifiedResource(); $file->rewind(); $filePath = $file->getPath() . '/' . $file->getFilename(); $stylus = new StylusCompiler(); $string = $stylus->parseFile($filePath); if (null !== $path) { $file2 = new FileObject($path, 'w+'); $file2->write($string); $string = true; } unset($file); unset($file2); return $string; }
/** * Minify function. Returns a minified content, or writes it to a file if path is specified. * * @param null|string $file * @return string|true */ public function compile($path = null) { // create a file from the given path, or a temproary resource of a max of 20 Mb $this->res = $path ? new FileObject($path, 'w+') : new TempFileObject($this->options['tmp'] . '/' . StringUtils::randString(50)); // merge all resources in the minfier's resource foreach ($this->resources as $handle) { while (!$handle->eof()) { $chunk = $handle->read(8192); $this->res->write($chunk); } unset($handle); $this->res->write("\n\n"); } $this->res->rewind(); // return the minified text as a string or as a file $string = null !== $path ? true : $this->res->read(); return $string; }
public function testInstance() { $file = new FileObject(__DIR__ . '/test1'); $this->assertTrue($file instanceof \Athem\Stdlib\FileObject); $this->assertTrue($file instanceof \Athem\Stdlib\FileInfo); $this->assertTrue($file instanceof \SplFileInfo); unset($file); $file = FileObject::openFileObject(__DIR__ . '/test1'); $this->assertTrue($file instanceof \Athem\Stdlib\FileObject); $this->assertTrue($file instanceof \Athem\Stdlib\FileInfo); $this->assertTrue($file instanceof \SplFileInfo); unset($file); }