mirror of
https://github.com/Respect/Validation.git
synced 2024-06-27 09:40:05 +02:00
Remove "buildRule" method from "Validator"
Because Validator uses a Factory to create rules, it does not make sense to create rules with this method anymore. Furthermore it goes over the responsibilities of the "Validator" to create objects. That said, the existence of such method is only one more point of maintenance and nothing that brings much values for our uses therefore it should be remove. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
parent
e4483b74f2
commit
3554288c60
|
@ -15,7 +15,6 @@ namespace Respect\Validation;
|
|||
|
||||
use finfo;
|
||||
use ReflectionClass;
|
||||
use Respect\Validation\Exceptions\ComponentException;
|
||||
use Respect\Validation\Exceptions\ValidationException;
|
||||
use Respect\Validation\Rules\AllOf;
|
||||
use Respect\Validation\Rules\Key;
|
||||
|
@ -192,21 +191,6 @@ class Validator extends AllOf
|
|||
return (new static())->__call($ruleName, $arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $ruleSpec
|
||||
* @param array $arguments
|
||||
*
|
||||
* @return Validatable
|
||||
*/
|
||||
public static function buildRule($ruleSpec, $arguments = [])
|
||||
{
|
||||
try {
|
||||
return Factory::getDefaultInstance()->rule($ruleSpec, $arguments);
|
||||
} catch (\Exception $exception) {
|
||||
throw new ComponentException($exception->getMessage(), $exception->getCode(), $exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @param array $arguments
|
||||
|
@ -215,7 +199,7 @@ class Validator extends AllOf
|
|||
*/
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
return $this->addRule(static::buildRule($method, $arguments));
|
||||
return $this->addRule(Factory::getDefaultInstance()->rule($method, $arguments));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue