BREAKING CHANGE: Adhere to PSR-12 coding standards.

- Model: where_in method was renamed as whereIn.
This commit is contained in:
kj
2025-09-07 11:07:07 -03:00
parent 0f46848d15
commit c9f467345b
10 changed files with 480 additions and 401 deletions

View File

@@ -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] . '"');
}
/**