Skip to content

Commit

Permalink
Yoda consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
mambax7 committed Oct 30, 2023
1 parent d2f1447 commit 4116726
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static function getVar($name, $default = null, $hash = 'default', $type =
{
// Ensure hash and type are uppercase
$hash = strtoupper($hash);
if ($hash === 'METHOD') {
if ('METHOD' === $hash) {
$hash = static::getMethod();
}
$type = strtoupper($type);
Expand Down Expand Up @@ -111,18 +111,18 @@ public static function getVar($name, $default = null, $hash = 'default', $type =
break;
}

if (isset($input[$name]) && $input[$name] !== null) {
if (isset($input[$name]) && null !== $input[$name]) {
// Get the variable from the input hash and clean it
$var = static::cleanVar($input[$name], $mask, $type);

// Handle magic quotes compatibility
if (function_exists('get_magic_quotes_gpc')
&& @get_magic_quotes_gpc() && ($var != $default)
&& ($hash !== 'FILES')
&& ('FILES' !== $hash)
) {
$var = static::stripSlashesRecursive($var);
}
} elseif ($default !== null) {
} elseif (null !== $default) {
// Clean the default value
$var = static::cleanVar($default, $mask, $type);
} else {
Expand Down Expand Up @@ -350,7 +350,7 @@ public static function getHeader($headerName, $default = '')
} else {
// From joyview - http://php.net/manual/en/function.getallheaders.php
foreach ($_SERVER as $name => $value) {
if (substr($name, 0, 5) === 'HTTP_') {
if ('HTTP_' === substr($name, 0, 5)) {
$translatedName = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($name, 5))));
$headers[$translatedName] = $value;
}
Expand All @@ -376,7 +376,7 @@ public static function getHeader($headerName, $default = '')
public static function hasVar($name, $hash = 'default')
{
$hash = strtoupper($hash);
if ($hash === 'METHOD') {
if ('METHOD' === $hash) {
$hash = strtoupper($_SERVER['REQUEST_METHOD']);
}

Expand All @@ -401,7 +401,7 @@ public static function hasVar($name, $hash = 'default')
public static function setVar($name, $value = null, $hash = 'method', $overwrite = true)
{
$hash = strtoupper($hash);
if ($hash === 'METHOD') {
if ('METHOD' === $hash) {
$hash = strtoupper($_SERVER['REQUEST_METHOD']);
}

Expand Down Expand Up @@ -475,7 +475,7 @@ public static function get($hash = 'default', $mask = 0)
{
$hash = strtoupper($hash);

if ($hash === 'METHOD') {
if ('METHOD' === $hash) {
$hash = strtoupper($_SERVER['REQUEST_METHOD']);
}

Expand Down Expand Up @@ -504,7 +504,7 @@ public static function get($hash = 'default', $mask = 0)
}

// Handle magic quotes compatibility
if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc() && ($hash !== 'FILES')) {
if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc() && ('FILES' !== $hash)) {
$input = static::stripSlashesRecursive($input);
}

Expand Down Expand Up @@ -552,7 +552,7 @@ protected static function cleanVar($var, $mask = 0, $type = null)
static $safeHtmlFilter = null;

// convert $var in array if $type is ARRAY
if (strtolower((string)$type) === 'array' && !is_array($var)) {
if ('array' === strtolower((string)$type) && !is_array($var)) {
$var = array($var);
}

Expand Down

0 comments on commit 4116726

Please sign in to comment.