1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-11 08:34:19 +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

@@ -59,9 +59,11 @@ class Minify_Cache_APC implements Minify_CacheInterface
return false;
}
return (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2))
? mb_strlen($this->_data, '8bit')
: strlen($this->_data);
if (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2)) {
return mb_strlen($this->_data, '8bit');
} else {
return strlen($this->_data);;
}
}
/**
@@ -85,9 +87,7 @@ class Minify_Cache_APC implements Minify_CacheInterface
*/
public function display($id)
{
echo $this->_fetch($id)
? $this->_data
: '';
echo $this->_fetch($id) ? $this->_data : '';
}
/**
@@ -99,9 +99,7 @@ class Minify_Cache_APC implements Minify_CacheInterface
*/
public function fetch($id)
{
return $this->_fetch($id)
? $this->_data
: '';
return $this->_fetch($id) ? $this->_data : '';
}
private $_exp = null;
@@ -126,9 +124,9 @@ class Minify_Cache_APC implements Minify_CacheInterface
$ret = apc_fetch($id);
if (false === $ret) {
$this->_id = null;
return false;
}
list($this->_lm, $this->_data) = explode('|', $ret, 2);
$this->_id = $id;

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;
}
/**

View File

@@ -62,9 +62,11 @@ class Minify_Cache_Memcache implements Minify_CacheInterface
return false;
}
return (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2))
? mb_strlen($this->_data, '8bit')
: strlen($this->_data);
if (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2)) {
return mb_strlen($this->_data, '8bit');
} else {
return strlen($this->_data);
}
}
/**
@@ -88,9 +90,7 @@ class Minify_Cache_Memcache implements Minify_CacheInterface
*/
public function display($id)
{
echo $this->_fetch($id)
? $this->_data
: '';
echo $this->_fetch($id) ? $this->_data : '';
}
/**
@@ -102,9 +102,7 @@ class Minify_Cache_Memcache implements Minify_CacheInterface
*/
public function fetch($id)
{
return $this->_fetch($id)
? $this->_data
: '';
return $this->_fetch($id) ? $this->_data : '';
}
private $_mc = null;
@@ -127,12 +125,14 @@ class Minify_Cache_Memcache implements Minify_CacheInterface
if ($this->_id === $id) {
return true;
}
$ret = $this->_mc->get($id);
if (false === $ret) {
$this->_id = null;
return false;
}
list($this->_lm, $this->_data) = explode('|', $ret, 2);
$this->_id = $id;

View File

@@ -60,7 +60,11 @@ class Minify_Cache_WinCache implements Minify_CacheInterface
return false;
}
return (function_exists('mb_strlen') && ((int) ini_get('mbstring.func_overload') & 2)) ? mb_strlen($this->_data, '8bit') : strlen($this->_data);
if (function_exists('mb_strlen') && ((int) ini_get('mbstring.func_overload') & 2)) {
return mb_strlen($this->_data, '8bit');
} else {
return strlen($this->_data);
}
}
/**
@@ -118,6 +122,7 @@ class Minify_Cache_WinCache implements Minify_CacheInterface
if ($this->_id === $id) {
return true;
}
$suc = false;
$ret = wincache_ucache_get($id, $suc);
if (!$suc) {
@@ -125,6 +130,7 @@ class Minify_Cache_WinCache implements Minify_CacheInterface
return false;
}
list($this->_lm, $this->_data) = explode('|', $ret, 2);
$this->_id = $id;

View File

@@ -56,9 +56,11 @@ class Minify_Cache_XCache implements Minify_CacheInterface
return false;
}
return (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2))
? mb_strlen($this->_data, '8bit')
: strlen($this->_data);
if (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2)) {
return mb_strlen($this->_data, '8bit');
} else {
return strlen($this->_data);
}
}
/**
@@ -80,9 +82,7 @@ class Minify_Cache_XCache implements Minify_CacheInterface
*/
public function display($id)
{
echo $this->_fetch($id)
? $this->_data
: '';
echo $this->_fetch($id) ? $this->_data : '';
}
/**
@@ -93,9 +93,7 @@ class Minify_Cache_XCache implements Minify_CacheInterface
*/
public function fetch($id)
{
return $this->_fetch($id)
? $this->_data
: '';
return $this->_fetch($id) ? $this->_data : '';
}
private $_exp = null;
@@ -116,12 +114,14 @@ class Minify_Cache_XCache implements Minify_CacheInterface
if ($this->_id === $id) {
return true;
}
$ret = xcache_get($id);
if (false === $ret) {
$this->_id = null;
return false;
}
list($this->_lm, $this->_data) = explode('|', $ret, 2);
$this->_id = $id;

View File

@@ -55,9 +55,7 @@ class Minify_Cache_ZendPlatform implements Minify_CacheInterface
*/
public function getSize($id)
{
return $this->_fetch($id)
? strlen($this->_data)
: false;
return $this->_fetch($id) ? strlen($this->_data) : false;
}
/**
@@ -71,9 +69,7 @@ class Minify_Cache_ZendPlatform implements Minify_CacheInterface
*/
public function isValid($id, $srcMtime)
{
$ret = ($this->_fetch($id) && ($this->_lm >= $srcMtime));
return $ret;
return ($this->_fetch($id) && ($this->_lm >= $srcMtime));
}
/**
@@ -83,9 +79,7 @@ class Minify_Cache_ZendPlatform implements Minify_CacheInterface
*/
public function display($id)
{
echo $this->_fetch($id)
? $this->_data
: '';
echo $this->_fetch($id) ? $this->_data : '';
}
/**
@@ -97,9 +91,7 @@ class Minify_Cache_ZendPlatform implements Minify_CacheInterface
*/
public function fetch($id)
{
return $this->_fetch($id)
? $this->_data
: '';
return $this->_fetch($id) ? $this->_data : '';
}
private $_exp = null;
@@ -121,12 +113,14 @@ class Minify_Cache_ZendPlatform implements Minify_CacheInterface
if ($this->_id === $id) {
return true;
}
$ret = output_cache_get($id, $this->_exp);
if (false === $ret) {
$this->_id = null;
return false;
}
list($this->_lm, $this->_data) = explode('|', $ret, 2);
$this->_id = $id;