Skip to content

Commit

Permalink
Add proper apiCLass info to exception
Browse files Browse the repository at this point in the history
  • Loading branch information
pierredup committed Jun 8, 2023
1 parent 09cd810 commit 73e8e95
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Payum/Core/ApiAwareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

use Payum\Core\Exception\LogicException;
use Payum\Core\Exception\UnsupportedApiException;
use function get_class;
use function is_object;

trait ApiAwareTrait
{
Expand All @@ -26,11 +28,11 @@ public function setApi($api)
}

if (is_string($this->apiClass) && !(class_exists($this->apiClass) || interface_exists($this->apiClass))) {
throw new LogicException(sprintf('Api class not found or invalid class. "%s", $this->apiClass', $this->apiClass));
throw new LogicException(sprintf('Api class not found or invalid class. "%s", $this->apiClass', $this->apiClass)
}

if (!$api instanceof $this->apiClass) {
throw new UnsupportedApiException(sprintf('Not supported api given. It must be an instance of %s', $this->apiClass));
throw new UnsupportedApiException(sprintf('Not supported api given. It must be an instance of %s', is_object($this->apiClass) ? get_class($this->apiClass) : $this->apiClass));
}

$this->api = $api;
Expand Down

0 comments on commit 73e8e95

Please sign in to comment.