<?php
abstract class ValidationHandlerAbstract
{
private $_nextHandler;
public function __construct()
{
$this->_nextHandler = null;
}
public function setHandler(ValidationHandlerAbstract $handler)
{
$this->_nextHandler = $handler;
return $this;
}
public function getNextHandler()
{
return $this->_nextHandler;
}
public function validate($input)
{
$result = $this->_execValidation($input);
if (!$result) {
return $this->_getErrorMessage();
} elseif (!is_null($this->getNextHandler())) {
return $this->getNextHandler()->validate($input);
} else {
return true;
}
}
protected abstract function _execValidation($input);
protected abstract function _getErrorMessage();
}