public static function extractParamsFromHeaderString(string $hmacHeader = null)
    {
        if ($hmacHeader !== null && preg_match('/^HMAC\s+(.*?)$/', $hmacHeader, $matches)) {
            if (\strpos($matches[1], ',') !== false) {
                $params = explode(',', trim($matches[1]));

                if (count($params) !== 3) {
                    return false;
                }

                return [
                    'access_token' => $params[0],
                    'hmac' => $params[1],
                    'salt' => $params[2],
                    'v' => 1,
                    'date' => null,
                ];
            } else {
                $params = \json_decode(\base64_decode($matches[1]), true);

                if (!isset($params['v']) ||
                    !isset($params['access_token']) ||
                    !isset($params['hmac']) ||
                    !isset($params['salt']) ||
                    !isset($params['v']) ||
                    !isset($params['date'])
                ) {
                    return false;
                }

                return $params;
            }
        }

        return false;
    }
public static function extractParamsFromHeaderString(string $hmacHeader = null)
    {
        if ($hmacHeader !== null && preg_match('/^HMAC\s+(.*?)$/', $hmacHeader, $matches)) {
            if (\strpos($matches[1], ',') !== false) {
                $params = explode(',', trim($matches[1]));

                if (count($params) !== 3) {
                    return false;
                }

                return [
                    'access_token' => $params[0],
                    'hmac' => $params[1],
                    'salt' => $params[2],
                    'v' => 1,
                    'date' => null,
                ];
            } else {
                $params = \json_decode(\base64_decode($matches[1]), true);

                if (!isset($params['v']) ||
                    !isset($params['access_token']) ||
                    !isset($params['hmac']) ||
                    !isset($params['salt']) ||
                    !isset($params['v']) ||
                    !isset($params['date'])
                ) {
                    return false;
                }

                return $params;
            }
        }

        return false;
    }
public static function extractParamsFromHeaderString ( string $ hmacHeader = null ) { if ( $ hmacHeader !== null && preg_match ( '/^HMAC\s+(.*?)$/' , $ hmacHeader , $ matches ) ) { if ( \ strpos ( $ matches [ 1 ] , ',' ) !== false ) { $ params = explode ( ',' , trim ( $ matches [ 1 ] ) ) ; if ( count ( $ params ) !== 3 ) { return false ; } return [ 'access_token' => $ params [ 0 ] , 'hmac' => $ params [ 1 ] , 'salt' => $ params [ 2 ] , 'v' => 1 , 'date' => null , ] ; } else { $ params = \ json_decode ( \ base64_decode ( $ matches [ 1 ] ) , true ) ; if ( ! isset ( $ params [ 'v' ] ) || ! isset ( $ params [ 'access_token' ] ) || ! isset ( $ params [ 'hmac' ] ) || ! isset ( $ params [ 'salt' ] ) || ! isset ( $ params [ 'v' ] ) || ! isset ( $ params [ 'date' ] ) ) { return false ; } return $ params ; } } return false ; }
Extracts the HMAC parameters from a header string

@param string $hmacHeader
@return array|boolean
Extracts the HMAC parameters from a header string