Merge pull request #68 from brandonlamb/features/psr-formatting

Apply some PSR formatting updates
This commit is contained in:
Vance Lucas 2014-05-27 11:48:18 -05:00
commit 746871558b

View File

@ -43,6 +43,7 @@ class Validator
// set lang in the follow order: constructor param, static::$_lang, default to en
$lang = $lang ?: static::lang();
// set langDir in the follow order: constructor param, static::$_langDir, default to package lang dir
$langDir = $langDir ?: static::langDir();
@ -52,7 +53,7 @@ class Validator
$langMessages = include $langFile;
static::$_ruleMessages = array_merge(static::$_ruleMessages, $langMessages);
} else {
throw new InvalidArgumentException("fail to load language file '$langFile'");
throw new \InvalidArgumentException("fail to load language file '$langFile'");
}
}
@ -89,7 +90,7 @@ class Validator
{
if (is_null($value)) {
return false;
} elseif(is_string($value) and trim($value) === '') {
} elseif (is_string($value) && trim($value) === '') {
return false;
}
return true;
@ -161,7 +162,7 @@ class Validator
*/
protected function validateInteger($field, $value)
{
return filter_var($value, FILTER_VALIDATE_INT) !== false;
return filter_var($value, \FILTER_VALIDATE_INT) !== false;
}
/**
@ -329,7 +330,7 @@ class Validator
*/
protected function validateIp($field, $value)
{
return filter_var($value, FILTER_VALIDATE_IP) !== false;
return filter_var($value, \FILTER_VALIDATE_IP) !== false;
}
/**
@ -341,7 +342,7 @@ class Validator
*/
protected function validateEmail($field, $value)
{
return filter_var($value, FILTER_VALIDATE_EMAIL) !== false;
return filter_var($value, \FILTER_VALIDATE_EMAIL) !== false;
}
/**
@ -355,7 +356,7 @@ class Validator
{
foreach ($this->validUrlPrefixes as $prefix) {
if (strpos($value, $prefix) !== false) {
return filter_var($value, FILTER_VALIDATE_URL) !== false;
return filter_var($value, \FILTER_VALIDATE_URL) !== false;
}
}
return false;
@ -749,7 +750,7 @@ class Validator
public static function addRule($name, $callback, $message = self::ERROR_DEFAULT)
{
if (!is_callable($callback)) {
throw new \InvalidArgumentException("Second argument must be a valid callback. Given argument was not callable.");
throw new \InvalidArgumentException('Second argument must be a valid callback. Given argument was not callable.');
}
static::$_rules[$name] = $callback;
@ -843,7 +844,7 @@ class Validator
if (is_array($params)) {
foreach ($params as $innerParams) {
array_unshift($innerParams, $ruleType);
call_user_func_array(array($this, "rule"), $innerParams);
call_user_func_array(array($this, 'rule'), $innerParams);
}
} else {
$this->rule($ruleType, $params);