Normalize a value into an AttributeFilter instance

@param  mixed $value Either a valid callback or an instance of AttributeFilter
@return \s9e\TextFormatter\Configurator\Items\AttributeFilter Normalized filter
329146
public function normalizeValue($value)
	{
		if (is_string($value) && preg_match('(^#\\w+$)', $value))
		{
			$value = AttributeFilterCollection::getDefaultFilter(substr($value, 1));
		}

		return parent::normalizeValue($value);
	}
260937
public function filter($value)
    {
        if (!is_string($value)) {
            return $value;
        }

        // Strip unicode bombs, and make sure all newlines are UNIX newlines.
        $value = preg_replace('{^\xEF\xBB\xBF|\x1A}', '', $value);
        $value = preg_replace('{\r\n?}', "\n", $value);

        $lambda = function($text) {
            $text = htmlspecialchars($text, ENT_COMPAT, 'UTF-8');
            /** @noinspection NotOptimalRegularExpressionsInspection */
            $text = preg_replace('/--/', '&mdash;', $text);
            $text = nl2br($text, false);
            $text = sprintf('<p>%s</p>', $text);

            return $text;
        };

        $paragraphs = preg_split('/\n{2,}/', $value, -1, PREG_SPLIT_NO_EMPTY);
        $paragraphs = array_map($lambda, $paragraphs);

        return implode("\n\n", $paragraphs);
    }
729490
private static function normalizeValue($value)
    {
        if (is_string($value)) {
            $value = str_ireplace(['&nbsp;', '&#160;'], ' ', $value);
            $value = trim($value);

            return ($value === '') ? null : $value;
        }

        return $value;
    }
867458
protected function normalizePath($value)
    {
        // array of paths = recursive
        if (is_array($value)) {
            foreach ($value as $i => $val) {
                $value[$i] = $this->normalizePath($val);
            }

            return $value;
        }

        $converter = new PathConverter(dirname($this->config['config_path']), $this->config['path']);

        return $converter->convert($value);
    }
1047061
public function sanitize($value)
    {
        if(!$value instanceof KObjectConfig)
        {
            if(is_string($value)) {
                $value = $this->getObject('object.config.factory')->fromString('xml', $value);
            } else {
                $value = $this->getObject('object.config.factory')->createFormat('xml', $value);
            }
        }

        return $value;
    }
293298
private function normalizeValue($value)
    {
        switch ($this->type) {
            case self::TYPE_STRING:
                return trim((string)$value);
            case self::TYPE_INT:
                return intval($value);
            case self::TYPE_FLOAT:
                return floatval($value);
        }

        throw new FilterException("Invalid filter value type \"{$this->type}\"");
    }
1273965
public function filter($value)
    {
        if (!is_scalar($value)) {
            return $value;
        }
        $value = (string) $value;

        $defaultScheme = $this->defaultScheme ?: $this->enforcedScheme;

        // Reset default scheme if it is not a known scheme
        if (!UriFactory::getRegisteredSchemeClass($defaultScheme)) {
            $defaultScheme = null;
        }

        try {
            $uri = UriFactory::factory($value, $defaultScheme);
            if ($this->enforcedScheme && (!$uri->getScheme())) {
                $this->enforceScheme($uri);
            }
        } catch (UriException $ex) {
            // We are unable to parse / enfore scheme with the given config and input
            return $value;
        }

        $uri->normalize();

        if (!$uri->isValid()) {
            return $value;
        }

        return $uri->toString();
    }
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;
    }
1320111
public function normalizeValue($value)
	{
		if ($value instanceof AbstractNormalization)
		{
			return $value;
		}

		if (is_callable($value))
		{
			return new Custom($value);
		}

		$className = 's9e\\TextFormatter\\Configurator\\TemplateNormalizations\\' . $value;

		return new $className;
	}
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;
    }
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;
    }
728344
public function normalizeValue($value)
	{
		if (is_string($value) && class_exists($value))
		{
			$value = new $value($this->configurator);
		}

		if ($value instanceof ConfiguratorBase)
		{
			return $value;
		}

		throw new InvalidArgumentException('PluginCollection::normalizeValue() expects a class name or an object that implements s9e\\TextFormatter\\Plugins\\ConfiguratorBase');
	}
1030092
protected function normalizeDateTime($value)
    {
        if ($value === '' || $value === null) {
            return $value;
        }

        if (!is_string($value) && !is_int($value) && !$value instanceof DateTime) {
            return $value;
        }

        if (is_int($value)) {
            //timestamp
            $value = new DateTime('@' . $value);
        } elseif (!$value instanceof DateTime) {
            $value = new DateTime($value);
        }

        return $value->format($this->format);
    }
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);
	}
347215
public function filter($value)
    {
        $params = (array) $this->options['callback_params'];
        array_unshift($params, $value);

        return call_user_func_array($this->options['callback'], $params);
    }
951143
public function normalizeValue($value)
	{
		$className  = $this->getFilterClassName();
		if ($value instanceof $className)
		{
			return $value;
		}

		if (!is_callable($value))
		{
			throw new InvalidArgumentException('Filter ' . var_export($value, true) . ' is neither callable nor an instance of ' . $className);
		}

		return new $className($value);
	}
779692
public function getReflClassFromComparisonValue( $value )
    {

        if( is_array($value) ) {
            $class = $this->namespace . '\\FindFilterComponent\\PropertyAccessArrayEquality';
        } elseif ( is_object($value) and $value instanceof Container ) {
            $class = $this->namespace . '\\FindFilterComponent\\PropertyAccessContainerEquality';
        } else {
            $class = $this->namespace . '\\FindFilterComponent\\PropertyAccessScalarEquality';
        }
        return new ReflectionClass($class);
    }