Skip to content

Commit

Permalink
Add colors to the filtering options, provide type definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
zoonman committed Jun 26, 2023
1 parent 32e3df5 commit 38742f1
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/Pixabay/PixabayClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class PixabayClient {
private $options = [];

/**
* Please consult for parameters on the documentation page https://pixabay.com/api/docs/
*
* @var array
*/
private $optionsList = [
Expand All @@ -43,6 +45,7 @@ class PixabayClient {
'category',
'min_width',
'min_height',
'colors',
'editors_choice',
'safesearch',
'page',
Expand Down Expand Up @@ -86,7 +89,7 @@ public function __construct(array $options)
* @param array $options
* @param bool $resetOptions
*/
private function parseOptions(array $options, $resetOptions = false)
private function parseOptions(array $options, bool $resetOptions = false)
{
foreach ($this->optionsList as $option) {
if (isset($options[$option])) {
Expand All @@ -101,13 +104,14 @@ private function parseOptions(array $options, $resetOptions = false)
/**
* Get Data from Pixabay API
*
* @param array $options
* @param bool $returnObject
* @param bool $resetOptions
* @param array $options
* @param bool $returnObject
* @param bool $resetOptions
* @param string $segment
* @return mixed
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function get(array $options = [], $returnObject = false, $resetOptions = false, $segment = self::SEGMENT_IMAGES)
public function get(array $options = [], bool $returnObject = false, bool $resetOptions = false, string $segment = self::SEGMENT_IMAGES)
{
$this->parseOptions($options, $resetOptions);
$response = $this->client->request('GET', self::API_ROOT . $segment, ['query' => $this->options]);
Expand All @@ -119,12 +123,13 @@ public function get(array $options = [], $returnObject = false, $resetOptions =
* Get Images from Pixabay API
*
* @param array $options
* @param bool $returnObject
* @param bool $resetOptions
* @param bool $returnObject
* @param bool $resetOptions
*
* @return mixed
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function getImages(array $options = [], $returnObject = false, $resetOptions = false)
public function getImages(array $options = [], bool $returnObject = false, bool $resetOptions = false)
{
return $this->get($options, $returnObject, $resetOptions, self::SEGMENT_IMAGES);
}
Expand All @@ -133,12 +138,13 @@ public function getImages(array $options = [], $returnObject = false, $resetOpti
* Get Videos from Pixabay API
*
* @param array $options
* @param bool $returnObject
* @param bool $resetOptions
* @param bool $returnObject
* @param bool $resetOptions
*
* @return mixed
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function getVideos(array $options = [], $returnObject = false, $resetOptions = false)
public function getVideos(array $options = [], bool $returnObject = false, bool $resetOptions = false)
{
return $this->get($options, $returnObject, $resetOptions, self::SEGMENT_VIDEOS);
}
Expand Down

0 comments on commit 38742f1

Please sign in to comment.