Run a value through the filters OR format attribute associated with the
parameter.

@param mixed $value Value to filter

@return mixed Returns the filtered value
@throws \RuntimeException when trying to format when no service
description is available.
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;
    }
395761
protected function getFilterValueFromUrl($value)
    {
        try {
            if ($item = $this->iriConverter->getItemFromIri($value)) {
                return $this->propertyAccessor->getValue($item, 'id');
            }
        } catch (\InvalidArgumentException $e) {
            // Do nothing, return the raw value
        }

        return $value;
    }
1239422
protected function formatValue($value)
    {
        // If the value is a date we'll format it according to the specified
        // date format.
        if ($value instanceof DateTime || $value instanceof Carbon)
        {
            $value = $value->format($this->grammar->getDateFormat());
        }

        return $value;
    }
367870
public function filter($value)
	{
		if (is_array($value) or (is_object($value) and $value instanceof \ArrayAccess))
		{
			return array_map([$this, 'filter'], $value);
		}

		return htmlentities($value, ENT_QUOTES | ENT_HTML5);
	}
439140
public function filter($value)
    {
        $dashToCamelCaseFilter       = new DashToCamelCase();
        $underscoreToCamelCaseFilter = new UnderscoreToCamelCase();

        $value = $dashToCamelCaseFilter->filter($value);
        $value = $underscoreToCamelCaseFilter->filter($value);

        return $value;
    }
48498
public function validate($value)
    {
        $original = $value;

        // Check if we are using a callable to get the pipeline
        if (is_callable($value) && $value instanceof \Closure) {
            $value = $value($this->container);
        }

        // Check if we have a valid pipeline instance
        if (!$value instanceof $this->contract) {
            throw new \RuntimeException('The configured value does not implement '. $this->contract);
        }

        // All good return original
        return $original;
    }
490700
public function filter($value) {
        if($value === null)
            return null;

        try {
            $sourceDT = new DateTime($value);
            $targetTZ = new DateTimeZone($this->options["timezone"] ? $this->options["timezone"] : date_default_timezone_get());
            $targetDT = $sourceDT;
            $targetDT->setTimeZone($targetTZ);

            return $targetDT->format($this->options["format"]);
        }
        catch(Exception $e) {
            return false;
        }
    }
321902
public function filter($value)
    {
        $isInternalAllowed = $this->builder->isVisibilityAllowed(Settings::VISIBILITY_INTERNAL);
        if ($isInternalAllowed) {
            $value->setDescription(preg_replace('/\{@internal\s(.+?)\}\}/', '$1', $value->getDescription()));

            return $value;
        }

        // remove inline @internal tags
        $value->setDescription(preg_replace('/\{@internal\s(.+?)\}\}/', '', $value->getDescription()));

        // if internal elements are not allowed; filter this element
        if ($value->getTags()->get('internal')) {
            return null;
        }

        return $value;
    }
629261
public function filter($value)
    {
	    if (is_string($value))
	        return new DateTime('@'.strtotime($value));
	    if ($value instanceof DateTime)
		    return $value;
	    if (is_int($value))
		    return new DateTime('@'.$value);
	    return null;
    }
1151459
public function getValue($value)
    {
        if (! ($om = $this->getObjectManager())) {
            throw new RuntimeException('No object manager was set');
        }

        if (! ($targetClass = $this->getTargetClass())) {
            throw new RuntimeException('No target class was set');
        }

        $metadata = $om->getClassMetadata($targetClass);

        if (is_object($value)) {
            if ($value instanceof Collection) {
                $data = [];

                foreach ($value as $object) {
                    $values = $metadata->getIdentifierValues($object);
                    $data[] = array_shift($values);
                }

                $value = $data;
            } else {
                $metadata   = $om->getClassMetadata(get_class($value));
                $identifier = $metadata->getIdentifierFieldNames();

                // TODO: handle composite (multiple) identifiers
                if (null !== $identifier && count($identifier) > 1) {
                    //$value = $key;
                } else {
                    $value = current($metadata->getIdentifierValues($value));
                }
            }
        }

        return $value;
    }
41211
public function filter($value) {
        
        //Validate
        if(!is_numeric($value) && $this->options["validate"]) {
            return Filter::ERR_INVALID;
        }
        $value = (double)$value;
        
        // Validate Values to Min/Max/Decimals
        if( (!$this->options["adjust"] && $value < $this->options["min"]) ||
            (!$this->options["adjust"] && $value > $this->options["max"]) ) {
            return Filter::ERR_INVALID;
        }

        //Validate decimal count
        if($this->options["decimals"] !== false && $this->options["round"] === false) {
            $decimalcount = strpos($value,".") !== false ? strlen($value) - strpos($value,".") - 1 : 0;
            if($decimalcount != $this->options["decimals"])
                return Filter::ERR_INVALID;
        }

        // Adjust values to Min/Max
        if($this->options["adjust"] && $this->options["min"] !== false) {
            $value = max($this->options["min"], $value);
        }
        if($this->options["adjust"] && $this->options["max"] !== false) {
            $value = min($this->options["max"], $value);
        }
        
        //Round/Floor if needed
        if($this->options["decimals"] !== false && $this->options["round"] !== false) {
            switch($this->options["round"]) {
                case self::SI_NUMBER_CEIL:    $value = ceil($value * pow(10,$this->options["decimals"])) / pow(10,$this->options["decimals"]);    break;
                case self::SI_NUMBER_FLOOR:   $value = self::floor($value, $this->options["decimals"]);    break;
                case self::SI_NUMBER_ROUND:   $value = round($value, $this->options["decimals"]);    break;
            }
        }
        
        return $value;        
    }
1319767
public function filter($value)
    {
        if ($this->encodingFormat !== null) {
            $firstChar = mb_substr($value, 0, 1, $this->encodingFormat);
            $rest = mb_substr($value, 1, null, $this->encodingFormat);
            return mb_strtoupper($firstChar, $this->encodingFormat) . $rest;
        }

        $firstChar = mb_substr($value, 0, 1);
        $rest = mb_substr($value, 1);

        return mb_strtoupper($firstChar) . $rest;
    }
1063075
public function apply(Rule $rule, $value)
    {
        if (!$this->container->has($rule->service)) {
            throw new \RuntimeException("Unable to find service '{$rule->service}' to execute defined rule.");
        }

        $service = $this->container->get($rule->service);

        if (! \is_callable([$service, $rule->method])) {
            throw new \RuntimeException("Unable to find the method '{$rule->method}' in service '{$rule->service}'.");
        }

        $method = $rule->method;

        return $service->$method($value);
    }
774357
public static function runAll($value)
    {
        foreach (get_class_methods(__CLASS__) as $method) {

            if (strpos($method, 'run') === 0) {
                continue;
            }
            $value = self::$method($value);
        }

        return $value;
    }
893966
protected function parseValue($value)
    {
        if ($this->isQuoted($value)) {
            return trim(preg_replace(static::ESCAPED_QUOTE_PATTERN, '\1', $value), static::QUOTE_CHARS);
        } elseif ($this->opensQuote($value)) {
            $value = $this->parseMultilineValue(ltrim($value, static::QUOTE_CHARS));
            if ($value === false) {
                throw new \RuntimeException('Error parsing ini.');
            }

            return $value;
        } elseif (is_numeric($value)) {
            if (strpos($value, '.') !== false) {
                return floatval($value);
            }
            return intval($value);
        } elseif (in_array(strtolower($value), ['true', 'false'])) {
            return (strtolower($value) === 'true');
        } else {
            return $value;
        }
    }
910137
public function filter($value)
    {
        if (!is_scalar($value)) {
            return $value;
        }

        $value = (string)$value;

        if ($this->options['encoding'] !== null) {
            $string = mb_strtolower($value, $this->options['encoding']);
            $upper = mb_strtoupper($string, $this->options['encoding']);
            preg_match('#(.)#us', $upper, $matches);
            $string = $matches[1] . mb_substr($string, 1, mb_strlen($string, $this->options['encoding']), $this->options['encoding']);
            return $string;
        }

        return ucfirst(strtolower($value));
    }
637885
private function format($value)
    {
        if (is_callable($this->formatter)) {
            $value = call_user_func($this->formatter, $value, $this->dataSet);
        }
        return $value;
    }