Skip to content

class Guzzle\Http\Message\Header could not be converted to int #263

@jrean

Description

@jrean

Hi,

$response = $client->getHttpClient()->getLastResponse();
var_dump($response);

// Guzzle\Http\Message\Response {#163 ...

Then:

var_dump(ResponseMediator::getApiLimit($response)); outputs:

PHP Notice:  Object of class Guzzle\Http\Message\Header could not be converted to int in /My/Path/To/Acme/vendor/knplabs/github-api/lib/Github/HttpClient/Message/ResponseMediator.php on line 46

https://github.com/KnpLabs/php-github-api/blob/master/lib/Github/HttpClient/Message/ResponseMediator.php

public static function getApiLimit(Response $response)
{
    $remainingCalls = $response->getHeader('X-RateLimit-Remaining');
    if (null !== $remainingCalls && 1 > $remainingCalls) {
        throw new ApiLimitExceedException($remainingCalls);
    }

    return $remainingCalls;
}

if (null !== $remainingCalls && 1 > $remainingCalls) the php notice comes from the 1 > $remainingCalls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions