Jyxo\Input\Chain::run PHP Method

run() private method

Starts filtering and validation.
private run ( mixed &$value ) : boolean
$value mixed Input value
return boolean
    private function run(&$value) : bool
    {
        foreach ($this->chain as $item) {
            if (self::FILTER === $item[0]) {
                $filter = $item[1];
                /* @var $filter \Jyxo\Input\FilterInterface */
                $value = $filter->filter($value);
            } elseif (self::VALIDATOR === $item[0]) {
                $validator = $item[1];
                /* @var $validator \Jyxo\Input\ValidatorInterface */
                if (!$validator->isValid($value)) {
                    if ($validator instanceof \Jyxo\Input\Validator\ErrorMessage) {
                        $this->errors[] = $validator->getError();
                    } elseif (isset($item[2])) {
                        $this->errors[] = $item[2];
                    }
                    return false;
                }
            } elseif (self::CONDITION === $item[0]) {
                $chain = $item[1];
                /* @var $chain \Jyxo\Input\Chain\Conditional */
                if ($chain->isValid($value)) {
                    $value = $chain->getValue();
                } else {
                    $this->errors = array_merge($this->errors, $chain->getErrors());
                    return false;
                }
            } elseif (self::WALK === $item[0]) {
                $chain = $item[1];
                /* @var $chain \Jyxo\Input\Chain */
                foreach ($value as &$sub) {
                    if ($chain->isValid($sub)) {
                        $sub = $chain->getValue($sub);
                    } else {
                        $this->errors = array_merge($this->errors, $chain->getErrors());
                        return false;
                    }
                }
            }
        }
        return true;
    }