Skip to content

Commit

Permalink
⬆️ Drop PHP 7.2 support
Browse files Browse the repository at this point in the history
Laravel 8.40.0 supports PHP above version 7.3. So this package needs support for PHP 7.3 and above only as well.
  • Loading branch information
marcreichel committed Jun 4, 2021
1 parent 670005b commit 7ffe034
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "A Laravel wrapper for version 4 of the IGDB API (Apicalypse) including webhook handling",
"keywords": ["laravel", "api-wrapper", "igdb", "igdb-api", "apicalypse", "wrapper"],
"require": {
"php": "^7.2 | ^7.3 | ^7.4 | ^8.0",
"php": "^7.3 | ^7.4 | ^8.0",
"laravel/framework": "^8.40.0",
"guzzlehttp/guzzle": "~6.0|~7.0",
"ext-json": "*"
Expand Down
6 changes: 4 additions & 2 deletions src/ApiHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace MarcReichel\IGDBLaravel;

use Exception;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Support\Facades\Cache;
Expand All @@ -16,6 +17,7 @@ class ApiHelper
*
* @return string
* @throws AuthenticationException
* @throws GuzzleException
*/
public static function retrieveAccessToken(): string
{
Expand All @@ -34,14 +36,14 @@ public static function retrieveAccessToken(): string
]);
$response = json_decode($guzzleClient->post(
'https://id.twitch.tv/oauth2/token?' . $query
)->getBody(), true);
)->getBody(), true, 512, JSON_THROW_ON_ERROR);

if (isset($response['access_token']) && $response['expires_in']) {
Cache::put($accessTokenCacheKey, (string)$response['access_token'], (int)$response['expires_in']);

$accessToken = (string)$response['access_token'];
}
} catch (GuzzleException $exception) {
} catch (Exception $exception) {
throw new AuthenticationException('Access Token could not be retrieved from Twitch.');
}

Expand Down
15 changes: 8 additions & 7 deletions src/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ protected function resetCacheLifetime(): void
*
* @return string
* @throws AuthenticationException
* @throws GuzzleException
*/
protected function retrieveAccessToken(): string
{
Expand Down Expand Up @@ -1420,7 +1421,7 @@ private function castDate($date)
* Execute the query.
*
* @return mixed|string
* @throws MissingEndpointException|AuthenticationException
* @throws MissingEndpointException|AuthenticationException|GuzzleException
*/
public function get()
{
Expand All @@ -1443,7 +1444,7 @@ function () use ($accessToken) {
'Authorization' => 'Bearer ' . $accessToken,
],
'body' => $this->getQuery(),
])->getBody(), true));
])->getBody(), true, 512, JSON_THROW_ON_ERROR));
} catch (Exception $exception) {
$this->handleRequestException($exception);
}
Expand Down Expand Up @@ -1541,7 +1542,7 @@ public function findOrFail(int $id)
* Execute the query and get the first result.
*
* @return mixed
* @throws MissingEndpointException|AuthenticationException
* @throws MissingEndpointException|AuthenticationException|GuzzleException
*/
public function first()
{
Expand All @@ -1554,7 +1555,7 @@ public function first()
* Return the total "count" result of the query.
*
* @return mixed
* @throws MissingEndpointException|AuthenticationException
* @throws MissingEndpointException|AuthenticationException|GuzzleException
*/
public function count()
{
Expand All @@ -1579,7 +1580,7 @@ function () use ($accessToken) {
'Authorization' => 'Bearer ' . $accessToken,
],
'body' => $this->getQuery(),
])->getBody(), true)['count'];
])->getBody(), true, 512, JSON_THROW_ON_ERROR)['count'];
} catch (Exception $exception) {
$this->handleRequestException($exception);
}
Expand All @@ -1598,7 +1599,7 @@ function () use ($accessToken) {
/**
* @return mixed
* @throws MissingEndpointException
* @throws ModelNotFoundException|AuthenticationException
* @throws ModelNotFoundException|AuthenticationException|GuzzleException
*/
public function firstOrFail()
{
Expand All @@ -1623,7 +1624,7 @@ public function firstOrFail()
* @param int $limit
*
* @return Paginator
* @throws MissingEndpointException|AuthenticationException
* @throws MissingEndpointException|AuthenticationException|GuzzleException
*/
public function paginate(int $limit = 10): Paginator
{
Expand Down

0 comments on commit 7ffe034

Please sign in to comment.