apply filter on given value

@param   \stubbles\values\Value  $value
@return  array
514109
public function apply(Value $value): array
    {
        if ($value->isEmpty()) {
            return $this->null();
        }

        if (strlen($value->value()) > $this->maxLength) {
            return $this->error('JSON_INPUT_TOO_BIG', ['maxLength' => $this->maxLength]);
        }

        $json = $value->value();
        if (!$this->isValidJsonStructure($json)) {
            return $this->error('JSON_INVALID');
        }

        $decodedJson = json_decode($json);
        $errorCode   = json_last_error();
        if (JSON_ERROR_NONE !== $errorCode) {
            return $this->error(
                    'JSON_SYNTAX_ERROR',
                    ['errorCode' => $errorCode,
                     'errorMsg'  => json_last_error_msg()
                    ]
            );
        }

        return $this->filtered($decodedJson);
    }
1198751
public function filter($value)
    {
        $lowerFilter = new \Zend_Filter_StringToLower();
        $value = $lowerFilter->filter(parent::filter($value));
        preg_match_all(self::SLUG_PATTERN, $value, $return);
        
        return implode($this->getWordSeparator(), $return[0]);
    }
993163
public function filter($value)
    {
        if (!is_array($value)) {
            $ascii = new \Mmi\Filter\Ascii;
            return preg_replace('!\-+!', '-', preg_replace('/[^\p{L}\p{N}]/u', '-', strtolower(trim($ascii->filter($value), '-'))));
        }
        foreach ($value as $key => $val) {
            $value[$key] = $this->filter($val);
        }
        return $value;
    }
993720
public function filter($value)
    {
        if (!is_string($value) && $value !== null) {
            return $value;
        }

        return $this->getAdapter()->decompress($value);
    }
1098392
public function filter($value)
    {
        return in_array($value, $this->getList(), $this->getStrict()) ? $value : null;
    }
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);
    }
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;        
    }
1012047
public function apply(Value $value): array
    {
        if ($value->isEmpty()) {
            return $this->filtered(new Token(null));
        }

        $value = $value->value();
        if (strtolower(trim(substr($value, 0, 7))) === 'bearer') {
            return $this->filtered(new Token(substr($value, 7)));
        }

        return $this->filtered(new Token($value));
    }
935155
public function filter($value)
    {
        if (!is_scalar($value)) {
            return $value;
        }
        $value = (string) $value;

        return basename($value);
    }
593680
public function setFilterAttribute($value)
    {
        return ($value) ? $this->attributes['filter'] = json_encode($value) : $this->attributes['filter'] = null;
    }
178396
public function filter($value)
    {
        if (is_int($value)) {
            return (string) $value;
        }
        if (! (is_float($value) || is_string($value))) {
            return $value;
        }
        $value = (string) $value;

        if (!StringUtils::hasPcreUnicodeSupport()) {
            // POSIX named classes are not supported, use alternative 0-9 match
            $pattern = '/[^0-9]/';
        } elseif (extension_loaded('mbstring')) {
            // Filter for the value with mbstring
            $pattern = '/[^[:digit:]]/';
        } else {
            // Filter for the value without mbstring
            $pattern = '/[\p{^N}]/';
        }

        return preg_replace($pattern, '', $value);
    }
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');
        }
    }
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;
        }
831454
protected function filter(&$value)
	{
		if (is_scalar($value)) {
			return htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
		} elseif (is_array($value)){
			array_walk_recursive($value, [$this, 'filter']);
		} elseif (is_object($value)) {
			foreach (get_object_vars($value) as $k => $v) {
				$value->$k = $this->filter($value);
			}
		}

		return $value;
	}
1073419
public function filter($value)
    {
        $values = explode(' ', $value);

        foreach ($values as &$val) {
            if (substr($val, -1) === '/') {
                $val = substr($val, 0, -1);
            }
        }

        return implode(' ', $values);
    }
411069
public function filter($value)
    {
        if (!is_scalar($value)) {
            return $value;
        }
        $value = (string) $value;

        return (int) $value;
    }
15260
public function filter($value) {
    	    	
    	$value   = str_replace(["\r", "\r\n", "\n"], '', $value);
    	$decoded = json_decode($value,true);
    	if(is_null($decoded)){
    		return null;
    	}    	
    	
    	switch($this->options["format"]){
    	    case self::DECODED:
    	        return $decoded;
    	    case self::JSON:
    	        return $value;
    	    case self::SERIALIZED:
    	        return serialize($decoded);
    	    default:
    	        throw new FilterException("unknown format for JSON filter specified");
    	}
    }