The "ReflectionClass" throws an exception if the class cannot be found,
for that reason the validation with the "class_exists()" function was
unnecessary.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
Make the ValidationException a little bit less mutable than before. All
its dependencies are now passed into the constructor.
This commit also make the Factory pass the translator to the exceptions
allowing to define the translator before the exception gets created.
This change is not the ideal one, later I would like to not need the
Singleton from the Factory to do that, but for now it seems like a good
approach.
One more thing that this commit does is to introduce the "id" for
Exceptions. Key can be either the defined "name" or the name of the rule
that throwed the exception. This method will be handy to identify
exceptions better.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
Before this change every create rule must have an exception. This commit
allows to create rules without specific exceptions, so when the
exception of the rule is not found Validation uses ValidationException
instead.
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
With this code the Factory class will be used also to create Exceptions.
In order to do that, the AbstractRule::reportError() was changed, so the
tests of the AbstractRule class.
What this commit also does:
- Port code to PHP 7;
- Do not keep the default instance of the Factory in the Validator
class;
- Make Factory final.
Appending a prefix to search new rules under required that the namespace
(prefix) being added always ended with a trailing namespace character so
rules could successfully be found under it. This ensures that the
separator is always present.
Changes a test for a rule which does not implement Respect's interface
to an actual class so we don't need to declare one to use as a stub.