slevomat /
csob-gateway
| 1 | <?php declare(strict_types = 1); |
||
| 2 | |||
| 3 | namespace SlevomatCsobGateway\Call\Extension; |
||
| 4 | |||
| 5 | use DateTimeImmutable; |
||
| 6 | use SlevomatCsobGateway\Call\ResponseExtensionHandler; |
||
| 7 | use SlevomatCsobGateway\Crypto\SignatureDataFormatter; |
||
| 8 | use function array_flip; |
||
| 9 | |||
| 10 | class MaskedCardNumberExtension implements ResponseExtensionHandler |
||
| 11 | { |
||
| 12 | |||
| 13 | public const NAME = 'maskClnRP'; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @param mixed[] $data |
||
| 17 | * @return MaskedCardNumberResponse |
||
| 18 | */ |
||
| 19 | 1 | public function createResponse(array $data): MaskedCardNumberResponse |
|
| 20 | { |
||
| 21 | 1 | return new MaskedCardNumberResponse( |
|
| 22 | 1 | $data['longMaskedCln'], |
|
| 23 | 1 | $data['maskedCln'], |
|
| 24 | 1 | $this->parseExpiration($data['expiration']) |
|
| 25 | ); |
||
| 26 | } |
||
| 27 | |||
| 28 | public function getSignatureDataFormatter(): SignatureDataFormatter |
||
| 29 | { |
||
| 30 | return new SignatureDataFormatter(array_flip(['extension', 'dttm', 'maskedCln', 'expiration', 'longMaskedCln'])); |
||
| 31 | } |
||
| 32 | |||
| 33 | 1 | private function parseExpiration(string $expiration): DateTimeImmutable |
|
| 34 | { |
||
| 35 | 1 | return DateTimeImmutable::createFromFormat('d/m/y', '01/' . $expiration)->modify('last day of this month today'); |
|
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 36 | } |
||
| 37 | |||
| 38 | } |
||
| 39 |