src/FilterFunnel.php
public function filter($value, $filters = null)
    {
        $this->messages = [];

        if ($this->optional && ($value === null || (is_string($value) && trim($value) === ''))) {
            return null;
        }

        foreach ($this->chain as $filter) {
            if ($filter instanceof ValidatorInterface) {
                if ($filter->isValid($value)) {
                    continue;
                }
                $this->messages = $filter->getMessages();

                return null;
            } elseif ($filter instanceof SanitizerInterface) {
                $value = $filter->sanitize($value);
            }
        }

        if ($filters) {
            $filters = explode('|', (string) $filters);

            if ($filters && current($filters) === 'optional') {
                array_shift($filters);
                if ($value === null || (is_string($value) && trim($value) === '')) {
                    return null;
                }
            }

            foreach ($filters as $filter) {
                $filter = trim($filter);
                $name = $filter;
                $params = [];

                if (strpos($filter,'(') !== false) {
                    $name = trim(substr($filter, 0, strpos($filter,'(')));
                    $params = substr($filter, strpos($filter,'(') + 1, -1);
                    $params = explode(',', $params);
                }

                if ($this->filterClassMap->hasValidator($name)) {
                    $validator = $this->filterClassMap->getValidator($name);
                    $validator = new $validator(...$params);
                    if ($validator->isValid($value)) {
                        continue;
                    }
                    $this->messages = $validator->getMessages();

                    return null;
                } elseif ($this->filterClassMap->hasSanitizer($name)) {
                    $sanitizer = $this->filterClassMap->getSanitizer($name);
                    $sanitizer = new $sanitizer(...$params);
                    $value = $sanitizer->sanitize($value);
                } else {
                    throw new \RuntimeException('filter "'.$name.'" not found');
                }
            }
        }

        return $value;
    }
public function filter($value, $filters = null)
    {
        $this->messages = [];

        if ($this->optional && ($value === null || (is_string($value) && trim($value) === ''))) {
            return null;
        }

        foreach ($this->chain as $filter) {
            if ($filter instanceof ValidatorInterface) {
                if ($filter->isValid($value)) {
                    continue;
                }
                $this->messages = $filter->getMessages();

                return null;
            } elseif ($filter instanceof SanitizerInterface) {
                $value = $filter->sanitize($value);
            }
        }

        if ($filters) {
            $filters = explode('|', (string) $filters);

            if ($filters && current($filters) === 'optional') {
                array_shift($filters);
                if ($value === null || (is_string($value) && trim($value) === '')) {
                    return null;
                }
            }

            foreach ($filters as $filter) {
                $filter = trim($filter);
                $name = $filter;
                $params = [];

                if (strpos($filter,'(') !== false) {
                    $name = trim(substr($filter, 0, strpos($filter,'(')));
                    $params = substr($filter, strpos($filter,'(') + 1, -1);
                    $params = explode(',', $params);
                }

                if ($this->filterClassMap->hasValidator($name)) {
                    $validator = $this->filterClassMap->getValidator($name);
                    $validator = new $validator(...$params);
                    if ($validator->isValid($value)) {
                        continue;
                    }
                    $this->messages = $validator->getMessages();

                    return null;
                } elseif ($this->filterClassMap->hasSanitizer($name)) {
                    $sanitizer = $this->filterClassMap->getSanitizer($name);
                    $sanitizer = new $sanitizer(...$params);
                    $value = $sanitizer->sanitize($value);
                } else {
                    throw new \RuntimeException('filter "'.$name.'" not found');
                }
            }
        }

        return $value;
    }
@param mixed $value

@throws \RuntimeException

@return mixed