Skip to content

Commit

Permalink
Merge pull request #5 from zepgram/develop
Browse files Browse the repository at this point in the history
[v2.0.0] add missing phpdoc for apiPool
  • Loading branch information
Benjamin Calef authored Feb 19, 2024
2 parents 0710701 + 21f76b0 commit 3ea4ad6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Service/ApiPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
namespace Zepgram\Rest\Service;

use ReflectionClass;
use ReflectionException;
use Zepgram\Rest\Exception\Technical\LogicException;
use Zepgram\Rest\Model\RequestAdapter;

Expand All @@ -26,9 +27,17 @@ public function __construct(
) {
}

/**
* @inheirtDoc
*/
public function execute(string $adapterName, array $rawData = []): mixed
{
$requestAdapterName = new ReflectionClass($adapterName);
try {
$requestAdapterName = new ReflectionClass($adapterName);
} catch (ReflectionException $e) {
throw new LogicException(__($adapterName . ' must be an instance of RequestAdapter'), $e);
}

if (!$requestAdapterName->isSubclassOf(RequestAdapter::class)) {
throw new LogicException(__($requestAdapterName . ' must be an instance of RequestAdapter'));
}
Expand Down
11 changes: 11 additions & 0 deletions Service/ApiPoolInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,23 @@

namespace Zepgram\Rest\Service;

use Zepgram\Rest\Exception\ExternalException;
use Zepgram\Rest\Exception\InternalException;
use Zepgram\Rest\Exception\Technical\InvalidContractException;
use Zepgram\Rest\Exception\Technical\LogicException;
use Zepgram\Rest\Exception\Technical\MissingBaseUriException;

interface ApiPoolInterface
{
/**
* @param string $adapterName
* @param array $rawData
* @return mixed
* @throws InternalException
* @throws InvalidContractException
* @throws LogicException
* @throws MissingBaseUriException
* @throws ExternalException
*/
public function execute(string $adapterName, array $rawData = []): mixed;
}

0 comments on commit 3ea4ad6

Please sign in to comment.