protected static function getJWTFromAuthHeader()
    {
        if ('testing' === env('APP_ENV')) {
            // getallheaders method is not available in unit test mode.
            return [];
        }

        if (!function_exists('getallheaders')) {
            function getallheaders()
            {
                if (!is_array($_SERVER)) {
                    return [];
                }

                $headers = [];
                foreach ($_SERVER as $name => $value) {
                    if (substr($name, 0, 5) == 'HTTP_') {
                        $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] =
                            $value;
                    }
                }

                return $headers;
            }
        }

        $token = null;
        $headers = getallheaders();
        $authHeader = array_get($headers, 'Authorization');
        if (strpos($authHeader, 'Bearer') !== false) {
            $token = substr($authHeader, 7);
        }

        return $token;
    }
protected static function getJWTFromAuthHeader()
    {
        if ('testing' === env('APP_ENV')) {
            // getallheaders method is not available in unit test mode.
            return [];
        }

        if (!function_exists('getallheaders')) {
            function getallheaders()
            {
                if (!is_array($_SERVER)) {
                    return [];
                }

                $headers = [];
                foreach ($_SERVER as $name => $value) {
                    if (substr($name, 0, 5) == 'HTTP_') {
                        $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] =
                            $value;
                    }
                }

                return $headers;
            }
        }

        $token = null;
        $headers = getallheaders();
        $authHeader = array_get($headers, 'Authorization');
        if (strpos($authHeader, 'Bearer') !== false) {
            $token = substr($authHeader, 7);
        }

        return $token;
    }
protected static function getJWTFromAuthHeader ( ) { if ( 'testing' === env ( 'APP_ENV' ) ) { // getallheaders method is not available in unit test mode. return [ ] ; } if ( ! function_exists ( 'getallheaders' ) ) { function getallheaders ( ) { if ( ! is_array ( $ _SERVER ) ) { return [ ] ; } $ headers = [ ] ; foreach ( $ _SERVER as $ name => $ value ) { if ( substr ( $ name , 0 , 5 ) == 'HTTP_' ) { $ headers [ str_replace ( ' ' , '-' , ucwords ( strtolower ( str_replace ( '_' , ' ' , substr ( $ name , 5 ) ) ) ) ) ] = $ value ; } } return $ headers ; } } $ token = null ; $ headers = getallheaders ( ) ; $ authHeader = array_get ( $ headers , 'Authorization' ) ; if ( strpos ( $ authHeader , 'Bearer' ) !== false ) { $ token = substr ( $ authHeader , 7 ) ; } return $ token ; }
Gets the token from Authorization header.

@return string
Gets the token from Authorization header .