for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Lavibi\Popoya;
class ValidatorChain extends AbstractValidator
{
/**
* @var ValidatorInterface[]
*/
protected $validators = [];
public function addValidator(ValidatorInterface $validator)
$this->validators[] = $validator;
return $this;
}
public function reset()
$this->validators = [];
parent::reset();
public function isValid($value)
$this->value = $this->standardValue = $value;
foreach ($this->validators as $validator) {
$result = $validator->isValid($this->standardValue);
if (!$result) {
$this->setErrorCode($validator->getMessageCode())->setErrorMessage($validator->getMessage());
return false;
$this->standardValue = $validator->getStandardValue();
return true;
protected function setErrorMessage($message)
$this->message = $message;
protected function setErrorCode($code)
$this->messageCode = $code;