BREAKING CHANGE: Adhere to PSR-12 coding standards.
- Model: where_in method was renamed as whereIn.
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Libs;
|
||||
|
||||
/**
|
||||
* Validator - DuckBrain
|
||||
*
|
||||
@@ -28,10 +31,8 @@
|
||||
* @website https://kj2.me
|
||||
* @licence MIT
|
||||
*/
|
||||
|
||||
namespace Libs;
|
||||
|
||||
class Validator {
|
||||
class Validator
|
||||
{
|
||||
public static string $lastFailed = '';
|
||||
|
||||
/**
|
||||
@@ -40,16 +41,17 @@ class Validator {
|
||||
* @param array $rulesList Lista de reglas.
|
||||
* @param Neuron $haystack Objeto al que se le verificarán las reglas.
|
||||
*
|
||||
* @return bool Retorna true solo si todas las reglas se cumplen y false en cuanto una falle.
|
||||
* @return bool Retorna true solo si todas las reglas se cumplen y false en cuanto una falle.
|
||||
*/
|
||||
public static function validateList(array $rulesList, Neuron $haystack): bool
|
||||
{
|
||||
foreach ($rulesList as $target => $rules) {
|
||||
$rules = preg_split('/\|/', $rules);
|
||||
foreach ($rules as $rule) {
|
||||
if (static::checkRule($haystack->{$target}, $rule))
|
||||
if (static::checkRule($haystack->{$target}, $rule)) {
|
||||
continue;
|
||||
static::$lastFailed = $target.'.'.$rule;
|
||||
}
|
||||
static::$lastFailed = $target . '.' . $rule;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -71,10 +73,11 @@ class Validator {
|
||||
$rule = [static::class, $arguments[0]];
|
||||
$arguments[0] = $subject;
|
||||
|
||||
if (is_callable($rule))
|
||||
if (is_callable($rule)) {
|
||||
return call_user_func_array($rule, $arguments);
|
||||
}
|
||||
|
||||
throw new \Exception('Bad rule: "'.preg_split('/::/', $rule)[1].'"' );
|
||||
throw new \Exception('Bad rule: "' . preg_split('/::/', $rule)[1] . '"');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user