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:
Henrique Moody 2018-07-24 17:23:36 +02:00
parent e4483b74f2
commit 3554288c60
No known key found for this signature in database
GPG key ID: 221E9281655813A6

View file

@ -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));
}
/**