1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-12 00:54:35 +02:00

Big style cleanup

This commit is contained in:
Steve Clay
2016-10-16 15:13:38 -04:00
parent 5fb7ea1ed1
commit 16c811cd93
23 changed files with 257 additions and 266 deletions

View File

@@ -54,13 +54,13 @@ class Minify_Cache_File implements Minify_CacheInterface
*/
public function store($id, $data)
{
$flag = $this->locking
? LOCK_EX
: null;
$flag = $this->locking ? LOCK_EX : null;
$file = $this->path . '/' . $id;
if (! @file_put_contents($file, $data, $flag)) {
$this->logger->warning("Minify_Cache_File: Write failed to '$file'");
}
// write control
if ($data !== $this->fetch($id)) {
@unlink($file);
@@ -107,15 +107,16 @@ class Minify_Cache_File implements Minify_CacheInterface
*/
public function display($id)
{
if ($this->locking) {
$fp = fopen($this->path . '/' . $id, 'rb');
flock($fp, LOCK_SH);
fpassthru($fp);
flock($fp, LOCK_UN);
fclose($fp);
} else {
if (!$this->locking) {
readfile($this->path . '/' . $id);
return;
}
$fp = fopen($this->path . '/' . $id, 'rb');
flock($fp, LOCK_SH);
fpassthru($fp);
flock($fp, LOCK_UN);
fclose($fp);
}
/**
@@ -127,20 +128,21 @@ class Minify_Cache_File implements Minify_CacheInterface
*/
public function fetch($id)
{
if ($this->locking) {
$fp = fopen($this->path . '/' . $id, 'rb');
if (!$fp) {
return false;
}
flock($fp, LOCK_SH);
$ret = stream_get_contents($fp);
flock($fp, LOCK_UN);
fclose($fp);
return $ret;
} else {
if (!$this->locking) {
return file_get_contents($this->path . '/' . $id);
}
$fp = fopen($this->path . '/' . $id, 'rb');
if (!$fp) {
return false;
}
flock($fp, LOCK_SH);
$ret = stream_get_contents($fp);
flock($fp, LOCK_UN);
fclose($fp);
return $ret;
}
/**