Leafo\ScssPhp\Server::checkedCachedCompile PHP Method

checkedCachedCompile() public method

Based on explicit input/output files does a full change check on cache before compiling.
public checkedCachedCompile ( string $in, string $out, boolean $force = false ) : string
$in string
$out string
$force boolean
return string Compiled CSS results
    public function checkedCachedCompile($in, $out, $force = false)
    {
        if (!is_file($in) || !is_readable($in)) {
            throw new ServerException('Invalid or unreadable input file specified.');
        }
        if (is_dir($out) || !is_writable(file_exists($out) ? $out : dirname($out))) {
            throw new ServerException('Invalid or unwritable output file specified.');
        }
        if ($force || $this->needsCompile($out, $etag)) {
            list($css, $etag) = $this->compile($in, $out);
        } else {
            $css = file_get_contents($out);
        }
        return $css;
    }

Usage Example

コード例 #1
0
ファイル: ServerTest.php プロジェクト: jimmyphong/scssphp
 public function testCheckedCachedCompile()
 {
     $server = new Server(__DIR__ . '/inputs/');
     $css = $server->checkedCachedCompile(__DIR__ . '/inputs/import.scss', '/tmp/scss.css');
     $this->assertFileExists('/tmp/scss.css');
     $this->assertFileExists('/tmp/scss.css.meta');
     $this->assertEquals($css, file_get_contents('/tmp/scss.css'));
     $this->assertNotNull(unserialize(file_get_contents('/tmp/scss.css.meta')));
 }
All Usage Examples Of Leafo\ScssPhp\Server::checkedCachedCompile