apply filter on given value

@param   \stubbles\values\Value  $value
@return  array
8728
public function apply(Value $value): array
    {
        $filter   = $this->filter;
        $errors   = [];
        $filtered = $filter($value, $errors);
        if (count($errors) > 0) {
            return $this->errors($errors);
        }

        return $this->filtered($filtered);
    }
990071
public function filterValue($value)
    {
        if ($value instanceof Element\AbstractElement) {
            $name      = $value->getName();
            $type      = $value->getType();
            $realValue = $value->getValue();
        } else {
            $type      = null;
            $name      = null;
            $realValue = $value;
        }
        foreach ($this->filters as $filter) {
            if (((null === $type) || (!in_array($type, $filter['excludeByType']))) &&
                ((null === $name) || (!in_array($name, $filter['excludeByName'])))) {
                if (is_array($realValue)) {
                    foreach ($realValue as $k => $v) {
                        $params        = array_merge([$v], $filter['params']);
                        $realValue[$k] = call_user_func_array($filter['call'], $params);
                    }
                } else {
                    $params    = array_merge([$realValue], $filter['params']);
                    $realValue = call_user_func_array($filter['call'], $params);
                }
            }
        }
        if (($value instanceof Element\AbstractElement) && (null !== $realValue) && ($realValue != '')) {
            $value->setValue($realValue);
        }
        return $realValue;
    }
1131969
public function apply(Value $value): array
    {
        if ($value->isEmpty()) {
            return $this->null();
        }

        try {
            return $this->filtered(new Day($value->value()));
        } catch (\InvalidArgumentException $iae) {
            return $this->error('DATE_INVALID');
        }
    }
1017529
public function apply($value)
    {
        $modified = false;

        foreach ($this->filters as $filter) {
            $result = $filter->apply($value);

            if ($result === false) {
                return false;
            } elseif ($result === true) {
            } else {
                $modified = true;
                $value    = $result;
            }
        }

        return $modified ? $value : true;
    }
382245
public function filter($value)
    {
        if (!is_string($value) && !is_numeric($value)) {
            return $value;
        }

        return $this->adapter->encrypt($value);
    }
738419
public function filter($value)
    {
        if (!is_scalar($value)) {
            return $value;
        }
        $value = (string) $value;

        return dirname($value);
    }
1090130
public function filter($value)
    {
        if (!is_scalar($value) && !is_array($value)) {
            return $value;
        }

        if ($this->options['pattern'] === null) {
            throw new Exception\RuntimeException(sprintf(
                'Filter %s does not have a valid pattern set',
                get_class($this)
            ));
        }

        return preg_replace($this->options['pattern'], $this->options['replacement'], $value);
    }
28057
private function filter(string $value) : string
    {
        foreach ($this->filters as $filter) {
            $value = $filter($value);
        }

        return $value;
    }
5365
public function filter($value)
    {
        // Formats are applied exclusively and supersed filters
        if ($this->format) {
            if (!$this->serviceDescription) {
                throw new \RuntimeException('No service description was set so '
                    . 'the value cannot be formatted.');
            }
            return $this->serviceDescription->format($this->format, $value);
        }

        // Convert Boolean values
        if ($this->type == 'boolean' && !is_bool($value)) {
            $value = filter_var($value, FILTER_VALIDATE_BOOLEAN);
        }

        // Apply filters to the value
        if ($this->filters) {
            foreach ($this->filters as $filter) {
                if (is_array($filter)) {
                    // Convert complex filters that hold value place holders
                    foreach ($filter['args'] as &$data) {
                        if ($data == '@value') {
                            $data = $value;
                        } elseif ($data == '@api') {
                            $data = $this;
                        }
                    }
                    $value = call_user_func_array(
                        $filter['method'],
                        $filter['args']
                    );
                } else {
                    $value = call_user_func($filter, $value);
                }
            }
        }

        return $value;
    }
550476
public function filter($value)
    {
        // build search array
        $search = [
            '= |\(|\)|\/|\,|\'|´|\-|\_|`|\.|\@|\||&=',
            '=á|à|â|ã|ą|ă|ā|Â|Á|À|Ã|Ą|Ă|Ā=i',
            '=å|Å=i',
            '=ä|æ|Ä|Æ=i',
            '=ç|ć|č|ċ|ĉ|Ç|Ć|Č|Ċ|Ĉ=i',
            '=ď|Ď=i',
            '=ð|Ð=i',
            '=é|è|ê|ë|ę|ě|ē|ė|Ê|É|È|Ë|Ę|Ě|Ē|Ė=i',
            '=ğ|ġ|ĝ|ģ|Ğ|Ġ|Ĝ|Ģ=i',
            '=ħ|ĥ|Ħ|Ĥ=i',
            '=í|ì|î|ï|ı|ĩ|į|ï|Î|Í|Ì|Ï|İ|Ĩ|Į|Ī=i',
            '=ĵ|Ĵ=i',
            '=ķ|ĸ|Ķ=i',
            '=ł|ľ|ĺ|ļ|Ł|Ľ|Ĺ|Ļ=i',
            '=ñ|ń|ň|ņ|Ñ|Ń|Ň|Ņ=i',
            '=ó|ò|ô|õ|ő|ō|Ô|Ó|Ò|Õ|Ő|Ō=i',
            '=ö|ø|Ö|Ø=i',
            '=ŕ|ř|ŗ|Ŕ|Ř|Ŗ=i',
            '=š|ś|ş|ŝ|Š|Ś|Ş|Ŝ=i',
            '=ß=i',
            '=ť|ţ|ŧ|Ť|Ţ|Ŧ=i',
            '=Þ|þ=i',
            '=ú|ù|û|ů|ű|ŭ|ų|ũ|ū|Û|Ú|Ù|Ů|Ű|Ŭ|Ų|Ũ|Ū=i',
            '=ü|Ü=i',
            '=ý|ÿ|Ý|Ÿ=i',
            '=ź|ž|ż|Ź|Ž|Ż=i',
        ];

        // build replace array
        $replace = [
            $this->delimiter,
            'a',
            'aa',
            'ae',
            'c',
            'd',
            'dj',
            'e',
            'g',
            'h',
            'i',
            'j',
            'k',
            'l',
            'n',
            'o',
            'oe',
            'r',
            's',
            'ss',
            't',
            'th',
            'u',
            'ue',
            'y',
            'z',
        ];

        // replace special characters
        $value = preg_replace($search, $replace, (string)$value);

        // remove other characters
        $value = preg_replace(
            '=[^a-z0-9' . $this->delimiter . ']*=i', '', $value
        );

        // replace double delimiter
        $value = preg_replace(
            '=' . $this->delimiter . '+=', $this->delimiter, $value
        );

        // strip out leading and ending delimiter
        $value = preg_replace(
            '=^' . $this->delimiter . '|' . $this->delimiter . '$=', '',
            $value
        );

        // convert to lower case and return
        return strtolower($value);
    }
801077
public function filter($value)
    {
        if (!$value instanceof User) {
            return array();
        }

        $info = $value->getInfo();

        return array(
            'id' => $value->getId(),
            'name' => $info->displayName,
            'image' => $info->image ? $info->image->uri : '',
            'email' => $info->email,
        );
    }
840790
public function apply(Value $value): array
    {
        list($value, $errors) = $this->filter->apply($value);
        if (count($errors) > 0) {
            return $this->errors($errors);
        }

        if (null === $value) {
            return $this->null();
        }

        if ($this->range->contains($value)) {
            return $this->filtered($value);
        }

        if ($this->range->allowsTruncate($value)) {
            return $this->filtered($this->range->truncateToMaxBorder($value));
        }

        return $this->errors($this->range->errorsOf($value));
    }
1095828
public function filter($value)
    {
        $chain = clone $this->filters;

        $valueFiltered = $value;
        foreach ($chain as $filter) {
            $valueFiltered = call_user_func($filter, $valueFiltered);
        }

        return $valueFiltered;
    }
916989
public function filter($value)
    {
        if (!is_string($value) && !is_array($value)) {
            return $value;
        }
        return str_replace($this->search, $this->replacement, $value);
    }
874414
public function filter($value)
        {
            // perform trimming according to the specified criteria
            switch($this->type) {
                case "left":
                    $value = ltrim($value, $this->chars);
                    break;
                case "right":
                    $value = rtrim($value,$this->chars);
                    break;
                default:
                    $value = trim($value,$this->chars);
                    break;
            }

            // we're left with the filtered value
            return $value;
        }
1034488
public function filterByValueLike($value)
    {
        $callback = function (BindingInterface $binding, $key) use ($value) {
            return strpos($binding->getValue(), $value) !== false;
        };

        return $this->filter($callback);
    }
829152
public function apply(Value $value): array
    {
        if ($value->isNull()) {
            return $this->null();
        }

        $float = $value->value();
        settype($float, 'float');
        if (empty($this->decimals)) {
            return $this->filtered($float);
        }

        return $this->filtered((int) ($float * pow(10, $this->decimals)));
    }