@param mixed $value
@param int $options

@return string
166345
public static function encode($value, int $options = null) : string
    {
        if ($options) {
            $encoded = json_encode($value, $options);
        } else {
            $encoded = json_encode($value);
        }

        if (!is_string($encoded)) {
            throw new \InvalidArgumentException(sprintf(
                "Json encode failed (%s) with '%s' and type '%s'",
                json_last_error(),
                json_last_error_msg(),
                gettype($encoded)
            ));
        }

        return $encoded;
    }
112489
public static function submit($value, array $options = [])
    {
        self::exclure($options, ['type', 'value']);

        return self::input('submit', 'null', $value, $options);
    }
1175335
public static function string(&$value, $options = ['length'=>null, 'regex'=>null, 'default'=>null])
    {
        $value = htmlspecialchars(trim($value));
        self::processString($value, $options);
        return $value;
    }
957631
protected static function processUNum(&$value, $options)
    {
        if (!isset($options['min']) || empty($options['min']) || $options['min'] < 0) {
            $options['min'] = 0;
        }
        self::processNum($value, $options);
    }
997888
public static function niceDatetime($value, array $options = []) {
		if (!isset($value)) return '';
		try {
			$server_timezone = self::$options['server_timezone_code'] ?? Application::get('php.date.timezone');
			$object = new DateTime($value, new DateTimeZone($server_timezone));
			// change timezone
			if (empty($options['skip_user_timezone'])) {
				$object->setTimezone(new DateTimeZone(self::$options['timezone_code']));
			}
			$value = i18n(null, $object->format('F')) . ' ' . $object->format('j') . self::$symbol_comma . ' ' . $object->format('Y');
			// process time
			$hours = intval($object->format('G'));
			$minutes = intval($object->format('i'));
			$seconds = intval($object->format('s'));
			// if we have time
			if (!($hours == 0 && $minutes == 0 && $seconds == 0)) {
				$timeformat = self::getDateFormat('time');
				$am_pm = stripos($timeformat, 'a') !== false;
				$timeformat = str_ireplace(['a', ' '], '', $timeformat);
				$time = $object->format($timeformat);
				$time = trim2($time, ':00$', '');
				$time = trim2($time, ':00$', '');
				if (!empty($time)) {
					$value.= ' ' . $time;
					if ($am_pm) {
						$value.= ' ' . str_ireplace(['am', 'pm'], [i18n(null, 'am', ['skip_i_symbol' => true]), i18n(null, 'pm', ['skip_i_symbol' => true])], $object->format('a'));
					}
				}
			}
		} catch (Exception $e) {
			// on exception we return as is
		}
		return $value;
	}
2385
public function check($value, $hashedValue, array $options = array()) {

        return strtoupper($this->make($value)) === strtoupper($hashedValue);
    }
1041243
public static function convert($value, $options = null)
    {
        if ($options === null) {
            $options = self::$options;
        }

        switch (strtolower($value)) {
            case 'true':
                return ($options & self::CONVERT_BOOL) ? true : $value;

            case 'false':
                return ($options & self::CONVERT_BOOL) ? false : $value;

            case 'null':
                return ($options & self::CONVERT_NULL) ? null : $value;
        }

        if (($options & self::CONVERT_INT) && ctype_digit($value)) {
            return (int) $value;
        }

        if (($options & self::STRIP_QUOTES) && !empty($value)) {
            return self::stripQuotes($value);
        }

        return $value;
    }
1217773
public static function json(&$value, $options = ['json_assoc'=>true, 'json_schema'=>[], 'default'=>null])
    {
        $json_assoc = isset($options['json_assoc']) && $options['json_assoc'] ? true : false;
        $value = @json_decode(trim($value), $json_assoc);

        if ($value !== null && $json_assoc && isset($options['json_schema']) && $options['json_schema'] && is_array($options['json_schema'])) {
            foreach ($options['json_schema'] as $field => $opt_arr) {
                self::validate(
                    $value[$field],
                    isset($opt_arr[0]) ? $opt_arr[0] : self::NONE_TYPE,
                    isset($opt_arr[1]) && is_array($opt_arr[1]) ? $opt_arr[1] : []
                );
            }
        } elseif ($value === null) {
            $value = isset($options['default']) ? $options['default'] : null;
        }

        return $value;
    }
682040
public function body($value = null, $options = [])
    {
        if (!func_num_args()) {
            return $this->_stream->toString();
        }
        $stream = $this->stream();
        $stream->close();
        $stream->add($value, $options);
        return $this;
    }
1346938
public static function encodeJson($value, int $options = JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION): string
    {
        return \json_encode($value, $options);
    }
534220
public static function niceTimestamp($value, array $options = []) {
		if (!isset($value)) return '';
		try {
			$server_timezone = self::$options['server_timezone_code'] ?? Application::get('php.date.timezone');
			$object = new DateTime($value, new DateTimeZone($server_timezone));
			// change timezone
			if (empty($options['skip_user_timezone'])) {
				$object->setTimezone(new DateTimeZone(self::$options['timezone_code']));
			}
			// now and date
			$now = new DateTime('now', new DateTimeZone($server_timezone));
			$other = new DateTime($object->format(self::getDateFormat('date')), new DateTimeZone($server_timezone));
			// if its today we show time
			if ($now->diff($other)->days === 0) {
				$value = $object->format(self::getDateFormat('time'));
			} else {
				$value = $object->format(self::getDateFormat('date'));
			}
		} catch (Exception $e) {
			// on exception we return as is
		}
		return $value;
	}
549027
public function label($name, $value = null, $options = [])
    {
        if (!$value) {
            return '';
        }
        $this->labels[] = $name;
        $options        = $this->html->attributes($options);
        $value          = e($this->formatLabel($name, $value));
        return '<label for="' . $name . '"' . $options . '>' . $value . '</label>';
    }
638136
public function filter($value, $options = [])
    {
        $value = (string) $value;
        if ($this->getEncoding()) {
            return mb_strtoupper($value, $this->getEncoding());
        }

        return strtoupper($value);
    }
24747
public function filter($value, array $options = [])
    {
        return is_string($value)
            ? filter_var(Str::lower(trim($value)), FILTER_SANITIZE_EMAIL)
            : $value;
    }
448547
public static function encode($value, $options = 0): string
	{
		$flags = \PHP_VERSION_ID >= 50400
			? (\JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES | ($options & self::PRETTY
					? \JSON_PRETTY_PRINT
					: 0))
			: 0;

		if (\PHP_VERSION_ID < 50500) {
			$json = Callback::invokeSafe('json_encode', [$value, $flags], static function ($message) { // needed to receive 'recursion detected' error

				throw new JsonException($message);
			});
		} else {
			$json = \json_encode($value, $flags);
		}

		$error = \json_last_error();

		if ($error) {
			$message = static::$messages[$error] ?? (\PHP_VERSION_ID >= 50500 ? \json_last_error_msg() : 'Unknown error');

			throw new JsonException($message, $error);
		}

		$json = \str_replace(["\xe2\x80\xa8", "\xe2\x80\xa9"], ['\u2028', '\u2029'], $json);

		return $json;
	}
827482
public static function float(&$value, $options = ['max'=>null, 'min'=>null, 'default'=>null])
    {
        $value = (float)$value;
        self::processNum($value, $options);
        return $value;
    }
1062181
private function interpret($value, $options = array())
    {
        $key = sprintf('%s|%s', (string) $value, implode('|', array_values($options)));

        if (isset ($this->interpretations[$key])) {
            return $this->interpretations[$key];
        }


        $config = new LexerConfig();

        $config = isset($options['delimiter']) ? $config->setDelimiter($options['delimiter']) : $config;
        $config = isset($options['enclosure']) ? $config->setEnclosure($options['enclosure']) : $config;
        $config = isset($options['escape']) ? $config->setEscape($options['escape']) : $config;

        $lexer = new Lexer($config);

        $rowCounter = 0;
        $columnSizes = array();

        $interpreter = new Interpreter();
        $interpreter->unstrict();
        $interpreter->addObserver(
            function (array $row) use (&$rowCounter, &$columnSizes) {
                $rowCounter ++;
                $rowLength = count($row);

                if (!isset($columnSizes[$rowLength])) {
                    $columnSizes[$rowLength] = array();
                }

                $columnSizes[$rowLength][] = $rowCounter;
            }
        );

        $lexer->parse($value, $interpreter);

        $this->interpretations[$key] = array(
            'rows' => $rowCounter,
            'columnSizes' => $columnSizes
        );

        return $this->interpretations[$key];
    }