Skip to content

Commit

Permalink
Url: Pass API key into method getApi()
Browse files Browse the repository at this point in the history
  • Loading branch information
VerifiedJoseph committed Oct 17, 2023
1 parent 5e02466 commit a42eba5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions include/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Api
*/
public function getDetails(string $type, string $parameter, string $eTag)
{
$url = Url::getApi($type, $parameter);
$url = Url::getApi($type, $parameter, Config::get('YOUTUBE_API_KEY'));

Check failure on line 28 in include/Api.php

View workflow job for this annotation

GitHub Actions / PHPStan

Parameter #3 $apiKey of static method App\Helper\Url::getApi() expects string, bool|string given.
$response = $this->fetch($url, $eTag);

if ($response['statusCode'] === 200 && empty($response['data']->items)) {
Expand All @@ -43,7 +43,7 @@ public function getDetails(string $type, string $parameter, string $eTag)
*/
public function getVideos(string $parameter)
{
$url = Url::getApi('videos', $parameter);
$url = Url::getApi('videos', $parameter, Config::get('YOUTUBE_API_KEY'));

Check failure on line 46 in include/Api.php

View workflow job for this annotation

GitHub Actions / PHPStan

Parameter #3 $apiKey of static method App\Helper\Url::getApi() expects string, bool|string given.
$response = $this->fetch($url);

return $response['data'];
Expand All @@ -57,7 +57,7 @@ public function getVideos(string $parameter)
*/
public function searchChannels(string $parameter): object
{
$url = Url::getApi('searchChannels', $parameter);
$url = Url::getApi('searchChannels', $parameter, Config::get('YOUTUBE_API_KEY'));

Check failure on line 60 in include/Api.php

View workflow job for this annotation

GitHub Actions / PHPStan

Parameter #3 $apiKey of static method App\Helper\Url::getApi() expects string, bool|string given.
$response = $this->fetch($url);

return $response['data'];
Expand All @@ -71,7 +71,7 @@ public function searchChannels(string $parameter): object
*/
public function searchPlaylists(string $parameter): object
{
$url = Url::getApi('searchPlaylists', $parameter);
$url = Url::getApi('searchPlaylists', $parameter, Config::get('YOUTUBE_API_KEY'));

Check failure on line 74 in include/Api.php

View workflow job for this annotation

GitHub Actions / PHPStan

Parameter #3 $apiKey of static method App\Helper\Url::getApi() expects string, bool|string given.
$response = $this->fetch($url);

return $response['data'];
Expand Down
5 changes: 3 additions & 2 deletions include/Helper/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,10 @@ public static function getThumbnail(string $videoId, string $type): string
*
* @param string $type API request type
* @param string $parameter API request Parameter
* @param string $apiKey YouTube API key
* @return string Returns url
*/
public static function getApi(string $type, string $parameter)
public static function getApi(string $type, string $parameter, string $apiKey)
{
$url = self::getEndpoint('api');

Expand All @@ -153,7 +154,7 @@ public static function getApi(string $type, string $parameter)
break;
}

return $url . '&prettyPrint=false&key=' . Config::get('YOUTUBE_API_KEY');
return $url . '&prettyPrint=false&key=' . $apiKey;
}

/**
Expand Down

0 comments on commit a42eba5

Please sign in to comment.