Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
webeweb committed May 27, 2020
1 parent 805e8c9 commit d16c6dc
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 242 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"ext-json": "*",
"guzzlehttp/guzzle": "^6.0",
"psr/log": "^1.0",
"webeweb/core-library": "^6.0"
"webeweb/core-library": "^6.6"
},
"require-dev": {
"phpunit/phpunit": "^5.7|^7.0"
Expand Down
22 changes: 0 additions & 22 deletions src/Exception/APIException.php

This file was deleted.

35 changes: 0 additions & 35 deletions src/Exception/AbstractException.php

This file was deleted.

6 changes: 3 additions & 3 deletions src/Provider/APIProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace WBW\Library\Pixabay\Provider;

use InvalidArgumentException;
use WBW\Library\Pixabay\Exception\APIException;
use WBW\Library\Core\Exception\ApiException;
use WBW\Library\Pixabay\Model\AbstractResponse;
use WBW\Library\Pixabay\Model\Request\SearchImagesRequest;
use WBW\Library\Pixabay\Model\Request\SearchVideosRequest;
Expand Down Expand Up @@ -49,7 +49,7 @@ protected function beforeReturnResponse(AbstractResponse $response) {
*
* @param SearchImagesRequest $searchImagesRequest The search images request.
* @return SearchImagesResponse Returns the search images response.
* @throws APIException Throws an API exception if an error occurs.
* @throws ApiException Throws an API exception if an error occurs.
* @throws InvalidArgumentException Throws an invalid argument exception if a parameter is missing.
*/
public function searchImages(SearchImagesRequest $searchImagesRequest) {
Expand All @@ -66,7 +66,7 @@ public function searchImages(SearchImagesRequest $searchImagesRequest) {
*
* @param SearchVideosRequest $searchVideosRequest The search videos request.
* @return SearchVideosResponse Returns the search videos response.
* @throws APIException Throws an API exception if an error occurs.
* @throws ApiException Throws an API exception if an error occurs.
* @throws InvalidArgumentException Throws an invalid argument exception if a parameter is missing.
*/
public function searchVideos(SearchVideosRequest $searchVideosRequest) {
Expand Down
78 changes: 6 additions & 72 deletions src/Provider/AbstractProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
use GuzzleHttp\Client;
use InvalidArgumentException;
use Psr\Log\LoggerInterface;
use WBW\Library\Pixabay\Exception\APIException;
use WBW\Library\Core\Exception\ApiException;
use WBW\Library\Core\Provider\AbstractProvider as BaseProvider;
use WBW\Library\Pixabay\Model\AbstractRequest;
use WBW\Library\Pixabay\Model\RateLimitTrait;

Expand All @@ -25,7 +26,7 @@
* @author webeweb <https://github.com/webeweb/>
* @package WBW\Library\Pixabay\Provider
*/
abstract class AbstractProvider {
abstract class AbstractProvider extends BaseProvider {

use RateLimitTrait;

Expand All @@ -36,34 +37,21 @@ abstract class AbstractProvider {
*/
const ENDPOINT_PATH = "https://pixabay.com/api";

/**
* Debug.
*
* @var bool
*/
private $debug;

/**
* Key.
*
* @var string
*/
private $key;

/**
* Logger.
*
* @var LoggerInterface
*/
private $logger;

/**
* Constructor.
*
* @param string $key The key.
* @param LoggerInterface|null $logger The logger.
*/
public function __construct($key = null, LoggerInterface $logger = null) {
parent::__construct($logger);
$this->setDebug(false);
$this->setKey($key);
$this->setLogger($logger);
Expand Down Expand Up @@ -92,7 +80,7 @@ private function buildConfiguration() {
* @param AbstractRequest $request The request.
* @param array $queryData The query data.
* @return string Returns the raw response.
* @throws APIException Throws an API exception if an error occurs.
* @throws ApiException Throws an API exception if an error occurs.
* @throws InvalidArgumentException Throws an invalid argument exception if a parameter is missing.
*/
protected function callAPI(AbstractRequest $request, array $queryData) {
Expand Down Expand Up @@ -124,19 +112,10 @@ protected function callAPI(AbstractRequest $request, array $queryData) {
return $response->getBody()->getContents();
} catch (Exception $ex) {

throw new APIException("Call Pixabay API failed", $ex);
throw new APIException("Call Pixabay API failed", 500, $ex);
}
}

/**
* Get the debug.
*
* @return bool Returns the debug.
*/
public function getDebug() {
return $this->debug;
}

/**
* Get the key.
*
Expand All @@ -146,40 +125,6 @@ public function getKey() {
return $this->key;
}

/**
* Get the logger.
*
* @return LoggerInterface Returns the logger.
*/
public function getLogger() {
return $this->logger;
}

/**
* Log an info.
*
* @param string $message The message.
* @param array $context The context.
* @return AbstractProvider Returns this provider.
*/
protected function logInfo($message, array $context) {
if (null !== $this->getLogger()) {
$this->getLogger()->info($message, $context);
}
return $this;
}

/**
* Set the debug.
*
* @param bool $debug The debug.
* @return AbstractProvider Returns this provider.
*/
public function setDebug($debug) {
$this->debug = $debug;
return $this;
}

/**
* Set the key.
*
Expand All @@ -190,15 +135,4 @@ public function setKey($key) {
$this->key = $key;
return $this;
}

/**
* Set the logger.
*
* @param LoggerInterface|null $logger The logger
* @return AbstractProvider Returns this provider
*/
protected function setLogger(LoggerInterface $logger = null) {
$this->logger = $logger;
return $this;
}
}
41 changes: 0 additions & 41 deletions tests/Exception/APIExceptionTest.php

This file was deleted.

41 changes: 0 additions & 41 deletions tests/Exception/AbstractExceptionTest.php

This file was deleted.

24 changes: 0 additions & 24 deletions tests/Fixtures/Exception/TestException.php

This file was deleted.

6 changes: 3 additions & 3 deletions tests/Provider/APIProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Exception;
use InvalidArgumentException;
use Psr\Log\LoggerInterface;
use WBW\Library\Pixabay\Exception\APIException;
use WBW\Library\Core\Exception\ApiException;
use WBW\Library\Pixabay\Model\Request\SearchImagesRequest;
use WBW\Library\Pixabay\Model\Request\SearchVideosRequest;
use WBW\Library\Pixabay\Model\Response\SearchImagesResponse;
Expand Down Expand Up @@ -88,7 +88,7 @@ public function testSearchImages() {
$this->assertInstanceOf(SearchImagesResponse::class, $res);
} catch (Exception $ex) {

$this->assertInstanceOf(APIException::class, $ex);
$this->assertInstanceOf(ApiException::class, $ex);
}
}

Expand Down Expand Up @@ -133,7 +133,7 @@ public function testSearchVideos() {
$this->assertInstanceOf(SearchVideosResponse::class, $res);
} catch (Exception $ex) {

$this->assertInstanceOf(APIException::class, $ex);
$this->assertInstanceOf(ApiException::class, $ex);
}
}
}

0 comments on commit d16c6dc

Please sign in to comment.