Nice duration

@param int $value
@param array $options
@return string
354670
public static function niceDuration($value, array $options = []) : string {
		if (empty($value)) return '';
		if ($value < 60) {
			return self::id($value) . ' ' . i18n(null, 'seconds');
		} else if ($value < 360) {
			return self::id(round($value / 60, 2)) . ' ' . i18n(null, 'minutes');
		} else {
			return self::id(round($value / 360, 2)) . ' ' . i18n(null, 'hours');
		}
	}
1109730
public function set($name, $value, array $options = [])
    {
        $options = $this->options($options);
        $value   = parent::set($name, $value, $options);

        return setcookie(
            $this->normalize($name),
            $value,
            $options[self::OPTION_EXPIRE],
            $options[self::OPTION_PATH],
            $options[self::OPTION_DOMAIN],
            false,
            $options[self::OPTION_HTTP_ONLY]
        );
    }
1052142
public static function isEmpty($value, $options = array())
    {
        $value_set = isset($value) && $value != '';

        return sprintf(self::boolean($value_set, $options), $value);
    }
933923
public static function xss($value, array $options = array()) {
        $options = $options + array('strip' => true);

        $value = str_replace("\0", '', $value);

        if (!$options['strip']) {

            // Remove any attribute starting with on or xmlns
            $value = preg_replace('/\s?(?:on[a-z]+|xmlns)\s?=\s?"(?:.*?)"/isu', '', $value);

            // Remove namespaced elements
            $value = preg_replace('/<\/?\w+:\w+(?:.*?)>/isu', '', $value);

            // Remove really unwanted tags
            do {
                $old = $value;
                $value = preg_replace('/<\/?(?:applet|base|bgsound|embed|frame|frameset|iframe|layer|link|meta|object|script|style|title|xml|audio|video)(?:.*?)>/isu', '', $value);
            } while ($old !== $value);
        }

        return static::html($value, $options);
    }
213287
public function apply($value, $options = [])
    {
        if (!$value) {
            return $value;
        }
        if (sizeof($options) != 2) {
            throw new InvalidArgumentException('The Sanitizer Format Date filter requires both the current date format as well as the target format.');
        }
        $currentFormat = trim($options[0]);
        $targetFormat  = trim($options[1]);
        return Carbon::createFromFormat($currentFormat, $value)->format($targetFormat);
    }
42785
public static function uInt(&$value, $options = ['max'=>null, 'min'=>null, 'default'=>null])
    {
        $value = (int)$value;
        self::processUNum($value, $options);
        return $value;
    }
239580
public static function Base64Encode ($value, $options = []) {
		$to_encoding = isset($options['to_encoding']) ? $options['to_encoding'] : false;
		if ($to_encoding !== false) {
			$from_encoding = isset($options['from_encoding']) ? $options['from_encoding'] : static::DEFAULT_ENCODING;
			$value = mb_convert_encoding($value, $to_encoding, $from_encoding);
		}
		return base64_encode($value);
	}
782276
final public static function hasLength ($value, array $options=[]) : bool
	{
		$valueLength = strlen($value);
		if (!self::hasValue($value)) new ErrorCode(1001);

		if (isset($options['max']) && ($valueLength > (int) $options['max']))
			return FALSE;

		if (isset($options['min']) && ($valueLength < (int) $options['min']))
			return FALSE;

		if (isset($options['exact']) && ($valueLength != (int) $options['exact']))
			return FALSE;

		return TRUE;
	}
21414
public static function toInteger($value, array $options = array())
    {
        $options['precision'] = 0;
        $options['number_format'] = Zend_Locale_Format::STANDARD;
        return self::toNumber($value, $options);
    }
648004
public function filter($value, $options = [])
    {
        do {
            // Treat $input as buffer on each loop, faster
            // than new var && Remove unwanted tags
            $input  = $value;
            $output = $this->stripTags($input);
            $output = $this->stripEncodedEntities($output);

            // Use 2nd input param if not empty or '0'
            if ($options['safe_level'] !== 0) {
                $output = $this->stripBase64($output);
            }

        } while ($output !== $input);

        return $output;
    }
157380
protected function mapValuesToOptions(array $value, array $options)
    {
        $result = [];
        foreach ($value as $key) {
            $result[] = $this->mapValueToOption($key, $options);
        }
        return $result;
    }
390730
public function filter($value, array $options = [])
    {
        if ( ! is_string($value)) return $value;

        $value = trim($value);

        if ( ! Str::startsWith($value, ['http://', 'https://'])) {
            $value = "http://$value";
        }

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

        return self::input('submit', 'null', $value, $options);
    }
352549
public function filter($value, $options = [])
    {
        $value    = (string) $value;
        $filtered = htmlentities(
            $value,
            $this->getQuoteStyle(),
            $this->getEncoding(),
            $this->getDoubleQuote()
        );

        if (strlen($value) && !strlen($filtered)) {
            if (!function_exists('iconv')) {
                $ex = new \Exception('Encoding mismatch has resulted in htmlentities errors.');
                throw $ex;
            }

            $enc      = $this->getEncoding();
            $value    = iconv('', $enc . '//IGNORE', $value);
            $filtered = htmlentities($value, $this->getQuoteStyle(), $enc, $this->getDoubleQuote());

            if (!strlen($filtered)) {
                $ex = new \Exception('Encoding mismatch has resulted in htmlentities errors.');
                throw $ex;
            }
        }

        return $filtered;
    }
1310593
public function cookie($key = '', $value = '', $options = null)
    {
        $defaultOptions = [
            'prefix' => '',
            'expire' => 86400,
            'path' => '/',
            'secure' => false,
            'httponly' => false,
        ];

        if (!is_null($options)) {
            if (is_numeric($options)) {
                $options = ['expire' => $options];
            } elseif (is_string($options)) {
                parse_str($options, $options);
            }

            $options = array_merge($defaultOptions, array_change_key_case($options));
        }

        if (!empty($options['httponly'])) {
            ini_set('session.cookie_httponly', 1);
        }

        if (is_null($key)) {
            if (empty($_COOKIE)) {
                return null;
            }

            $prefix = empty($value) ? $options['prefix'] : $value;
            if (!empty($prefix)) {
                foreach ($_COOKIE as $key => $val) {
                    if (0 === stripos($key, $prefix)) {
                        setcookie($key, '', time() - 3600, $options['path'], $options['domain'], $options['secure'], $options['httponly']);
                        unset($_COOKIE[$key]);
                    }
                }
            }

            return null;
        } elseif ('' === $key) {
            // Get All Cookie
            return $_COOKIE;
        }

        $key = $options['prefix'] . str_replace('.', '_', $key);
        if ('' === $value) {
            if (isset($_COOKIE[$key])) {
                $value = $_COOKIE[$key];
                if (0 === strpos($value, 'kotori:')) {
                    $value = substr($value, 6);
                    return array_map('urldecode', json_decode(MAGIC_QUOTES_GPC ? stripslashes($value) : $value, true));
                } else {
                    return $value;
                }
            } else {
                return null;
            }
        } else {
            if (is_null($value)) {
                setcookie($key, '', time() - 3600, $options['path'], $options['domain'], $options['secure'], $options['httponly']);
                unset($_COOKIE[$key]); // Delete Cookie
            } else {
                // Set Cookie
                if (is_array($value)) {
                    $value = 'kotori:' . json_encode(array_map('urlencode', $value));
                }

                $expire = !empty($options['expire']) ? time() + intval($options['expire']) : 0;
                setcookie($key, $value, $expire, $options['path'], $options['domain'], $options['secure'], $options['httponly']);
                $_COOKIE[$key] = $value;
            }
        }

        return null;
    }
1060797
private function resolveTimeValue($value)
    {
        if (is_int($value)) {
            return $value;
        }

        $timestamp = strtotime($value);

        if (false === $timestamp) {
            throw new InvalidArgumentException(
                "'{$value}' is invalid time string"
            );
        }

        return $timestamp;
    }
916273
public function set($key, $value, array $options = [])
    {
        $value = (string)$value;
        $options = array_merge($this->options, $options);

        // File: ext/standard/head.c, Line: 92
        if (empty($key) || preg_match("/[=,; \t\r\n\013\014]/", $key)) {
            throw new \InvalidArgumentException(sprintf('Invalid name \'%s\'.', $key));
        }

        // convert expiration time to a Unix timestamp
        if ($options['expire'] instanceof \DateTimeInterface) {
            $options['expire'] = $options['expire']->format('U');
        } 
        elseif (!is_numeric($options['expire'])) {
            $options['expire'] = strtotime($options['expire']);

            if (false === $options['expire'] || -1 === $options['expire']) {
                throw new \InvalidArgumentException('The expiration time is not valid.');
            }
        }

        setcookie ($key, $value,
            $options['expire'],
            $options['path'],
            $options['domain'],
            $options['secure'],
            $options['httponly']
        );

        return $this;
    }