Airship\Engine\AutoPilot::isActiveCabinKey PHP Method

isActiveCabinKey() public static method

Does a given cabin key match the current HTTP host, port, and path?
public static isActiveCabinKey ( string $cabinKey = '*', boolean $https_only = false, string $scheme = '', string $activeHost = '', string $uri = '' ) : boolean
$cabinKey string
$https_only boolean
$scheme string
$activeHost string
$uri string
return boolean
    public static function isActiveCabinKey(string $cabinKey = '*', bool $https_only = false, string $scheme = '', string $activeHost = '', string $uri = '') : bool
    {
        if (empty($uri)) {
            $uri = $_SERVER['REQUEST_URI'] ?? '';
        }
        if (empty($scheme)) {
            $scheme = self::isHTTPSConnection() ? 'https' : 'http';
        }
        if ($cabinKey === '*') {
            return true;
        }
        if ($cabinKey[0] === '*') {
            if ($cabinKey[1] === '/') {
                // */some_dir/
                $pattern = \preg_quote(Binary::safeSubstr($cabinKey, 2), '#');
                if (\preg_match('#^/' . $pattern . '#', $uri) === 1) {
                    return $https_only ? self::forceHTTPS() : true;
                }
            }
        } else {
            if (empty($activeHost)) {
                $activeHost = $_SERVER['HTTP_HOST'] ?? 'localhost';
            }
            $pos = \strpos($cabinKey, '/');
            if ($pos === false && \preg_match('#^' . \preg_quote($cabinKey, '#') . '#', $uri)) {
                return $https_only ? self::forceHTTPS($scheme) : true;
            } elseif ($pos !== false) {
                $sub = Binary::safeSubstr($cabinKey, $pos);
                $host = Binary::safeSubstr($cabinKey, 0, $pos);
                if (\strtolower($activeHost) === \strtolower($host) && \preg_match('#^' . \preg_quote($sub, '#') . '#', $uri)) {
                    return $https_only ? self::forceHTTPS($scheme) : true;
                }
            } elseif (\strtolower($activeHost) === \strtolower($cabinKey)) {
                return $https_only ? self::forceHTTPS($scheme) : true;
            }
        }
        return false;
    }