sailthru/Sailthru_Client.php
private function parseRateLimitHeaders($headers) {
        if ($headers === null) {
            return null;
        }

        $header_lines = explode("\n", $headers);
        $rate_limit_headers = [ ];
        foreach ($header_lines as $hl) {
            if (strpos($hl, "X-Rate-Limit-Limit") !== FALSE && !isset($rate_limit_headers['limit'])) {
                list($header_name, $header_value) = explode(":", $hl, 2);
                $rate_limit_headers['limit'] = intval($header_value);
            } else if (strpos($hl, "X-Rate-Limit-Remaining") !== FALSE && !isset($rate_limit_headers['remaining'])) {
                list($header_name, $header_value) = explode(":", $hl, 2);
                $rate_limit_headers['remaining'] = intval($header_value);
            } else if (strpos($hl, "X-Rate-Limit-Reset") !== FALSE && !isset($rate_limit_headers['reset'])) {
                list($header_name, $header_value) = explode(":", $hl, 2);
                $rate_limit_headers['reset'] = intval($header_value);
            }

            if (count($rate_limit_headers) === 3) {
                return $rate_limit_headers;
            }
        }

        return null;
    }
private function parseRateLimitHeaders($headers) {
        if ($headers === null) {
            return null;
        }

        $header_lines = explode("\n", $headers);
        $rate_limit_headers = [ ];
        foreach ($header_lines as $hl) {
            if (strpos($hl, "X-Rate-Limit-Limit") !== FALSE && !isset($rate_limit_headers['limit'])) {
                list($header_name, $header_value) = explode(":", $hl, 2);
                $rate_limit_headers['limit'] = intval($header_value);
            } else if (strpos($hl, "X-Rate-Limit-Remaining") !== FALSE && !isset($rate_limit_headers['remaining'])) {
                list($header_name, $header_value) = explode(":", $hl, 2);
                $rate_limit_headers['remaining'] = intval($header_value);
            } else if (strpos($hl, "X-Rate-Limit-Reset") !== FALSE && !isset($rate_limit_headers['reset'])) {
                list($header_name, $header_value) = explode(":", $hl, 2);
                $rate_limit_headers['reset'] = intval($header_value);
            }

            if (count($rate_limit_headers) === 3) {
                return $rate_limit_headers;
            }
        }

        return null;
    }
private function parseRateLimitHeaders ( $ headers ) { if ( $ headers === null ) { return null ; } $ header_lines = explode ( "\n" , $ headers ) ; $ rate_limit_headers = [ ] ; foreach ( $ header_lines as $ hl ) { if ( strpos ( $ hl , "X-Rate-Limit-Limit" ) !== FALSE && ! isset ( $ rate_limit_headers [ 'limit' ] ) ) { list ( $ header_name , $ header_value ) = explode ( ":" , $ hl , 2 ) ; $ rate_limit_headers [ 'limit' ] = intval ( $ header_value ) ; } else if ( strpos ( $ hl , "X-Rate-Limit-Remaining" ) !== FALSE && ! isset ( $ rate_limit_headers [ 'remaining' ] ) ) { list ( $ header_name , $ header_value ) = explode ( ":" , $ hl , 2 ) ; $ rate_limit_headers [ 'remaining' ] = intval ( $ header_value ) ; } else if ( strpos ( $ hl , "X-Rate-Limit-Reset" ) !== FALSE && ! isset ( $ rate_limit_headers [ 'reset' ] ) ) { list ( $ header_name , $ header_value ) = explode ( ":" , $ hl , 2 ) ; $ rate_limit_headers [ 'reset' ] = intval ( $ header_value ) ; } if ( count ( $ rate_limit_headers ) === 3 ) { return $ rate_limit_headers ; } } return null ; }
parse rate limit headers from http response
@param string $headers
@return array|null
parse rate limit headers from http response