Skip to content

Commit

Permalink
PHP CS
Browse files Browse the repository at this point in the history
  • Loading branch information
SmetDenis committed Feb 23, 2016
1 parent 26d0827 commit cbb3780
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 28 deletions.
4 changes: 2 additions & 2 deletions src/Arr.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static function unique($array, $keepKeys = false)
* Check is key exists
*
* @param string $key
* @param array $array
* @param mixed $array
* @param bool $returnValue
* @return mixed
*/
Expand All @@ -70,7 +70,7 @@ public static function key($key, $array, $returnValue = false)
* Check is value exists in the array
*
* @param string $value
* @param array $array
* @param mixed $array
* @param bool $returnKey
* @return mixed
*
Expand Down
6 changes: 2 additions & 4 deletions src/Dates.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static function factory($time = null, $timeZone = null)
/**
* Return a DateTimeZone object based on the current timezone.
*
* @param string $timezone
* @param mixed $timezone
* @return \DateTimeZone
*/
public static function timezone($timezone = null)
Expand All @@ -96,9 +96,7 @@ public static function timezone($timezone = null)
return $timezone;
}

if (!$timezone) {
$timezone = date_default_timezone_get();
}
$timezone = $timezone ?: date_default_timezone_get();

return new DateTimeZone($timezone);
}
Expand Down
19 changes: 16 additions & 3 deletions src/FS.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,22 +333,35 @@ protected static function _setPerms($filename, $isFlag, $perm)
// Set only the user writable bit (file is owned by us)
if ($isMyUid) {
$add = intval('0' . $perm . $perm . $perm, 8);
return chmod($filename, (fileperms($filename) | intval('0' . $perm . $perm . $perm, 8)) ^ $add);
return self::_chmod($filename, $perm, $add);
}

// Set only the group writable bit (file group is the same as us)
if ($isMyGid) {
$add = intval('00' . $perm . $perm, 8);
return chmod($filename, (fileperms($filename) | intval('0' . $perm . $perm . $perm, 8)) ^ $add);
return self::_chmod($filename, $perm, $add);
}

// Set the world writable bit (file isn't owned or grouped by us)
$add = intval('000' . $perm, 8);
return chmod($filename, (fileperms($filename) | intval('0' . $perm . $perm . $perm, 8)) ^ $add);
return self::_chmod($filename, $perm, $add);
}
//@codeCoverageIgnoreEnd
}

/**
* Chmod alias
*
* @param string $filename
* @param int $perm
* @param int $add
* @return bool
*/
protected static function _chmod($filename, $perm, $add)
{
return chmod($filename, (fileperms($filename) | intval('0' . $perm . $perm . $perm, 8)) ^ $add);
}

/**
* @param string $path
* @return string
Expand Down
2 changes: 1 addition & 1 deletion src/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static function download($filename, $content = false)
{
if (!headers_sent()) {
// Required for some browsers
if (Vars::bool(Sys::iniGet('zlib.output_compression'))) {
if (Sys::iniGet('zlib.output_compression')) {
Sys::iniSet('zlib.output_compression', 'Off');
}

Expand Down
5 changes: 1 addition & 4 deletions src/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,13 +350,10 @@ public static function isMBString()
{
static $isLoaded;

if (null == $isLoaded) {
if (null === $isLoaded) {
$isLoaded = extension_loaded('mbstring');

if ($isLoaded) {
Sys::iniSet('mbstring.internal_encoding', self::$encoding);
Sys::iniSet('mbstring.http_input', self::$encoding);
Sys::iniSet('mbstring.http_output', self::$encoding);
mb_internal_encoding(self::$encoding);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Sys.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static function getHome()
public static function iniSet($varName, $newValue)
{
if (self::isFunc('ini_set')) {
return @ini_set($varName, $newValue);
return Filter::bool(ini_set($varName, $newValue));
}

return null;
Expand All @@ -86,7 +86,7 @@ public static function iniSet($varName, $newValue)
public static function iniGet($varName)
{
if (self::isFunc('ini_get')) {
return ini_get($varName);
return Filter::bool(ini_get($varName));
}

return null;
Expand Down
13 changes: 5 additions & 8 deletions src/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,10 @@ public static function addArg(array $newParams, $uri = null)
$nuri = self::buildAll($puri);

// Make the URI consistent with our input
if ($nuri[0] === '/' && strstr($uri, '/') === false) {
$nuri = substr($nuri, 1);
}

if ($nuri[0] === '?' && strstr($uri, '?') === false) {
$nuri = substr($nuri, 1);
foreach (array('/', '?') as $char) {
if ($nuri[0] === $char && strstr($uri, $char) === false) {
$nuri = substr($nuri, 1);
}
}

return rtrim($nuri, '?');
Expand Down Expand Up @@ -128,9 +126,8 @@ public static function path()

// Get the rest of the URL
if (!Arr::key('REQUEST_URI', $_SERVER)) {
// Microsoft IIS doesn't set REQUEST_URI by default
//$url .= $_SERVER['PHP_SELF'];

// Microsoft IIS doesn't set REQUEST_URI by default
if ($queryString = Arr::key('QUERY_STRING', $_SERVER, true)) {
$url .= '?' . $queryString;
}
Expand Down
7 changes: 3 additions & 4 deletions src/Vars.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ class Vars
/**
* Converts many english words that equate to true or false to boolean.
*
* @param string $string The string to convert to boolean
* @param bool $default The value to return if we can't match any yes/no words
* @param string $string The string to convert to boolean
* @return boolean
*
* @deprecated See JBZoo\Utils\Filter
*/
public static function bool($string, $default = false)
public static function bool($string)
{
return Filter::bool($string, $default);
return Filter::bool($string);
}

/**
Expand Down

0 comments on commit cbb3780

Please sign in to comment.