Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/AndroidServicesApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ public function __construct(

/**
* @throws AndroidServiceException|JsonException
* @phpcs:disable Generic.Files.LineLength.TooLong
* @link https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptionsv2 Purchases.subscriptionsV2
* */
* @phpcs:enable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think only @link part needs to be excluded from phpcs checking - am I right? If so, change it please:

/**
* @phpcs:disable Generic.Files.LineLength.TooLong
* @link https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptionsv2 Purchases.subscriptionsV2
* @phpcs:enable
*@throws AndroidServiceException|JsonException
*/

*/
public function getPurchaseSubscriptionV2(
AndroidPublisherModelInterface $androidPublisherModel
): ?SubscriptionPurchaseV2 {
Expand Down Expand Up @@ -66,8 +68,10 @@ public function getPurchaseSubscriptionV2(

/**
* @throws AndroidServiceException|JsonException
* @phpcs:disable Generic.Files.LineLength.TooLong
* @link https://developers.google.com/android-publisher/api-ref/rest/v3/monetization.subscriptions.basePlans.offers Monetization.subscriptions.basePlans.offers
* */
* @phpcs:enable
*/
public function getBasePlanOffers(
AndroidPublisherModelInterface $androidPublisherModel
): ?ListSubscriptionOffersResponse {
Expand Down Expand Up @@ -99,7 +103,9 @@ public function getBasePlanOffers(

/**
* @throws AndroidServiceException|JsonException
* @phpcs:disable Generic.Files.LineLength.TooLong
* @link https://developers.google.com/android-publisher/api-ref/rest/v3/monetization.subscriptions Monetization.subscriptions
* @phpcs:enable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as above? ;)

*/
public function getPackageSubscriptions(
AndroidPublisherModelInterface $androidPublisherModel
Expand Down
5 changes: 4 additions & 1 deletion src/DependencyInjection/AndroidServicesExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@

class AndroidServicesExtension extends Extension
{
/**@throws Exception */
/**
* @suppressWarnings(PHPMD.UnusedFormalParameter)
* @throws Exception
*/
public function load(array $configs, ContainerBuilder $container): void
{
$loader = new YamlFileLoader(
Expand Down
9 changes: 8 additions & 1 deletion src/Factory/Authenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Google\Client;
use Google\Exception;
use IM\Fabric\Bundle\AndroidServicesBundle\Traits\HasAndroidServiceException;
use JsonException;

/**
Expand All @@ -14,6 +15,8 @@
*/
class Authenticator
{
use HasAndroidServiceException;

public function __construct(
private string $googleCredentials,
private Client $client
Expand All @@ -32,6 +35,10 @@ public function getAuthenticatedClient(string|array $scopes): Client
/** @throws JsonException */
private function getAuthConfig(): array
{
return json_decode($this->googleCredentials, true, 512, JSON_THROW_ON_ERROR);
try {
return json_decode($this->googleCredentials, true, 512, JSON_THROW_ON_ERROR);
} catch (JsonException $exception) {
$this->throwAndroidServiceException($exception->getMessage(), $exception->getCode());
}
}
}
2 changes: 1 addition & 1 deletion src/Resources/config/services.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
parameters:
app.deployed_env: '%env(string:DEPLOYED_ENV)%'
app.google_creds: 'env(GOOGLE_API_SERVICE_ACCOUNT_CREDENTIALS)%'
app.google_creds: '%env(GOOGLE_API_SERVICE_ACCOUNT_CREDENTIALS)%'
services:
# default configuration for services in *this* file
_defaults:
Expand Down
5 changes: 4 additions & 1 deletion tests/phpunit/Unit/AndroidServiceApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

/** @SuppressWarnings("LongVariable") */
/**
* @SuppressWarnings("LongVariable")
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* */
class AndroidServiceApiTest extends TestCase
{
use MockeryPHPUnitIntegration;
Expand Down
7 changes: 5 additions & 2 deletions tests/phpunit/Unit/Factory/AuthenticatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Google\Client;
use Google\Exception;
use IM\Fabric\Bundle\AndroidServicesBundle\Exception\AndroidServiceException;
use IM\Fabric\Bundle\AndroidServicesBundle\Factory\Authenticator;
use JsonException;
use Mockery;
Expand All @@ -30,11 +31,13 @@ class AuthenticatorTest extends TestCase
"client_x509_cert_url": "mock_url"
}';

/**@throws Exception*/
/**@throws Exception
* @throws JsonException
*/
public function testItThrowsAnExceptionIfTheCertIsNotValidJson(): void
{
$client = Mockery::mock(Client::class);
$this->expectException(JsonException::class);
$this->expectException(AndroidServiceException::class);
$unit = new Authenticator('bad json key', $client);
$unit->getAuthenticatedClient(self::MOCK_SCOPE);
}
Expand Down