public function value($value, $type = null) {
		if (!isset($value)) {
			return null;
		}

		$type = self::dataTypeOrDefault($type);

		if ($type === self::DATA_TYPE_EMAIL || $type === self::DATA_TYPE_URL || $type === self::DATA_TYPE_IP) {
			$value = \trim($value);
		}

		$filtered = \filter_var($value, self::determineFilterMode($type), self::composeFilterFlags($type));

		return self::applyPostProcessing($filtered, $type);
	}
public function value($value, $type = null) {
		if (!isset($value)) {
			return null;
		}

		$type = self::dataTypeOrDefault($type);

		if ($type === self::DATA_TYPE_EMAIL || $type === self::DATA_TYPE_URL || $type === self::DATA_TYPE_IP) {
			$value = \trim($value);
		}

		$filtered = \filter_var($value, self::determineFilterMode($type), self::composeFilterFlags($type));

		return self::applyPostProcessing($filtered, $type);
	}
public function value ( $ value , $ type = null ) { if ( ! isset ( $ value ) ) { return null ; } $ type = self :: dataTypeOrDefault ( $ type ) ; if ( $ type === self :: DATA_TYPE_EMAIL || $ type === self :: DATA_TYPE_URL || $ type === self :: DATA_TYPE_IP ) { $ value = \ trim ( $ value ) ; } $ filtered = \ filter_var ( $ value , self :: determineFilterMode ( $ type ) , self :: composeFilterFlags ( $ type ) ) ; return self :: applyPostProcessing ( $ filtered , $ type ) ; }
Validates, filters and typecasts the given value

@param mixed $value the value to process
@param int|null $type one of the constants from this class starting with `DATA_TYPE_` or `null`
@return mixed|null the validated, filtered and typecast value of the requested data type
Validates filters and typecasts the given value