Skip to content

Commit

Permalink
Fix sonar issue
Browse files Browse the repository at this point in the history
  • Loading branch information
giansalex committed May 2, 2023
1 parent 7e6f004 commit 0c1425b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/ws/src/Api/ApiFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Exception;
use Greenter\Services\Api\BasicToken;
use Greenter\Services\Api\TokenStoreInterface;
use Greenter\Services\InvalidServiceResponseException;
use Greenter\Sunat\GRE\Api\AuthApiInterface;
use Greenter\Sunat\GRE\Api\CpeApi;
use Greenter\Sunat\GRE\Api\CpeApiInterface;
Expand Down Expand Up @@ -80,7 +81,7 @@ private function getToken(?string $clientId, ?string $secret, ?string $user, ?st

$token = $result->getAccessToken();
if (empty($token)) {
throw new Exception('Cliente No autorizado');
throw new InvalidServiceResponseException('Cliente No autorizado');
}

$expire = $this->addSeconds(new DateTime(), $result->getExpiresIn());
Expand Down
3 changes: 2 additions & 1 deletion packages/ws/tests/Ws/Api/ApiFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use DateTime;
use Greenter\Api\ApiFactory;
use Greenter\Api\InMemoryStore;
use Greenter\Services\InvalidServiceResponseException;
use Greenter\Sunat\GRE\Api\AuthApiInterface;
use Greenter\Sunat\GRE\Api\CpeApi;
use Greenter\Sunat\GRE\Model\ApiToken;
Expand Down Expand Up @@ -38,7 +39,7 @@ public function testCreate()

public function testInvalidToken()
{
$this->expectException(\Exception::class);
$this->expectException(InvalidServiceResponseException::class);
list ($auth, $client, $store) = $this->deps(1,'');
$factory = new ApiFactory($auth, $client, $store, null);
$factory->create('x', 'x', '20123456780MODDATOS', 'moddatos');
Expand Down

0 comments on commit 0c1425b

Please sign in to comment.