Skip to content

Commit

Permalink
OP-377 - Add fix for PHPSpec, PHPStan and run ECS
Browse files Browse the repository at this point in the history
  • Loading branch information
SzymonKostrubiec committed Jul 25, 2024
1 parent 4f5bd4f commit 443f722
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
5 changes: 5 additions & 0 deletions spec/Action/NotifyActionSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,13 @@ function it_execute(
FactoryInterface $stateMachineFactory,
StateMachineInterface $stateMachine
) {
$params = [
'authorisationId' => '123'
];
$request->getModel()->willReturn($arrayObject);
$request->getFirstModel()->willReturn($payment);
$mercanetBnpParibasBridge->getAuthorisationId()->willReturn('123');
$payment->getDetails()->willReturn($params);
$mercanetBnpParibasBridge->isPostMethod()->willReturn(true);
$mercanetBnpParibasBridge->paymentVerification()->willReturn(true);
$stateMachineFactory->get($payment, PaymentTransitions::GRAPH)->willReturn($stateMachine);
Expand Down
2 changes: 1 addition & 1 deletion spec/Bridge/MercanetBnpParibasBridgeSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function it_payment_verification_has_been_thrown(
{
$request->isMethod('POST')->willReturn(true);
$requestStack->getCurrentRequest()->willReturn($request);

$this->setSecretKey('123');
$this
->shouldThrow(\InvalidArgumentException::class)
->during('paymentVerification', ['key'])
Expand Down
10 changes: 4 additions & 6 deletions src/Bridge/MercanetBnpParibasBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@
namespace BitBag\MercanetBnpParibasPlugin\Bridge;

use BitBag\MercanetBnpParibasPlugin\Legacy\Mercanet;
use BitBag\MercanetBnpParibasPlugin\Legacy\ShaComposer;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;

final class MercanetBnpParibasBridge implements MercanetBnpParibasBridgeInterface
{
private RequestStack $requestStack;

/** @phpstan-ignore-next-line We should not change our business logic now*/
private ShaComposer $secretKey;
private string $secretKey;

private string $merchantId;

Expand All @@ -38,7 +36,7 @@ public function __construct(RequestStack $requestStack)
}

/** @phpstan-ignore-next-line We should not change our business logic now*/
public function createMercanet(ShaComposer $secretKey): Mercanet
public function createMercanet(string $secretKey): Mercanet
{
return new Mercanet($secretKey);
}
Expand Down Expand Up @@ -70,13 +68,13 @@ public function isPostMethod(): bool
}

/** @phpstan-ignore-next-line We should not change our business logic now*/
public function getSecretKey(): ShaComposer
public function getSecretKey(): string
{
return $this->secretKey;
}

/** @phpstan-ignore-next-line We should not change our business logic now*/
public function setSecretKey(ShaComposer $secretKey): void
public function setSecretKey(string $secretKey): void
{
$this->secretKey = $secretKey;
}
Expand Down
9 changes: 3 additions & 6 deletions src/Bridge/MercanetBnpParibasBridgeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,21 @@
namespace BitBag\MercanetBnpParibasPlugin\Bridge;

use BitBag\MercanetBnpParibasPlugin\Legacy\Mercanet;
use BitBag\MercanetBnpParibasPlugin\Legacy\ShaComposer;

interface MercanetBnpParibasBridgeInterface
{
/** @phpstan-ignore-next-line We should not change our business logic now*/
public function createMercanet(ShaComposer $secretKey): Mercanet;
public function createMercanet(string $secretKey): Mercanet;

public function paymentVerification(): bool;

public function getAuthorisationId(): string;

public function isPostMethod(): bool;

/** @phpstan-ignore-next-line We should not change our business logic now*/
public function getSecretKey(): ShaComposer;
public function getSecretKey(): string;

/** @phpstan-ignore-next-line We should not change our business logic now*/
public function setSecretKey(ShaComposer $secretKey): void;
public function setSecretKey(string $secretKey): void;

public function getMerchantId(): string;

Expand Down
6 changes: 3 additions & 3 deletions src/Legacy/Mercanet.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Mercanet
];

/** @phpstan-ignore-next-line We should not change our business logic now*/
private ShaComposer $secretKey;
private string $secretKey;

private string $pspURL = self::TEST;

Expand Down Expand Up @@ -123,7 +123,7 @@ public static function getCurrencies(): array
}

/** @phpstan-ignore-next-line We should not change our business logic now*/
public function __construct(ShaComposer $secret)
public function __construct(string $secret)
{
$this->secretKey = $secret;
}
Expand Down Expand Up @@ -530,7 +530,7 @@ public function toParameterString(): string
}

/** @phpstan-ignore-next-line We should not change our business logic now*/
public static function createFromArray(ShaComposer $shaComposer, array $parameters): PaymentRequest|static
public static function createFromArray(string $shaComposer, array $parameters): PaymentRequest|static
{
/** @phpstan-ignore-next-line Unsafe usage of new static() */
$instance = new static($shaComposer);
Expand Down

0 comments on commit 443f722

Please sign in to comment.