efellemedia / DigitalOceanV2

PHP 5.4+ library which helps you to interact with the DigitalOcean API V2
MIT License
0 stars 1 forks source link

fix array to string conversion #4

Open porter707 opened 4 years ago

porter707 commented 4 years ago

When using the GuzzleHttpAdapter and calling the RateLimit API to return the current usage limits I get the following PHP notices:

[11-Nov-2019 10:12:40 UTC] PHP Notice:  Array to string conversion in /digitalocean-v2/src/Adapter/GuzzleHttpAdapter.php on line 121
[11-Nov-2019 10:12:40 UTC] PHP Notice:  Array to string conversion in /digitalocean-v2/src/Adapter/GuzzleHttpAdapter.php on line 122
[11-Nov-2019 10:12:40 UTC] PHP Notice:  Array to string conversion in /digitalocean-v2/src/Adapter/GuzzleHttpAdapter.php on line 123

The response that comes back from the GuzzleHttpAdapter looks like this:

[Ratelimit-Limit] => Array(
    [0] => 5000
)
[Ratelimit-Remaining] => Array(
    [0] => 4992
)
[Ratelimit-Reset] => Array(
    [0] => 1573465757
)

And the final RateLimit object looks like this:

DigitalOceanV2\Entity\RateLimit Object
(
    [limit] => 0
    [remaining] => 0
    [reset] => 0
)

The following changes fixes the issue and returns the values correctly

The final RateLimit Object with these changes looks like this:

DigitalOceanV2\Entity\RateLimit Object
(
    [limit] => 5000
    [remaining] => 4990
    [reset] => 1573465757
)