| Conditions | 7 |
| Paths | 4 |
| Total Lines | 30 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 7 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types = 1); |
||
| 20 | 2 | public function send(ApiClient $apiClient, array $data): PaymentResponse |
|
| 21 | { |
||
| 22 | 2 | if (array_key_exists('resultCode', $data) && is_numeric($data['resultCode'])) { |
|
| 23 | 2 | $data['resultCode'] = (int) $data['resultCode']; |
|
| 24 | } |
||
| 25 | |||
| 26 | 2 | if (array_key_exists('paymentStatus', $data) && is_numeric($data['paymentStatus'])) { |
|
| 27 | 2 | $data['paymentStatus'] = (int) $data['paymentStatus']; |
|
| 28 | } |
||
| 29 | |||
| 30 | 2 | $response = $apiClient->createResponseByData($data, new SignatureDataFormatter([ |
|
| 31 | 2 | 'payId' => null, |
|
| 32 | 'dttm' => null, |
||
| 33 | 'resultCode' => null, |
||
| 34 | 'resultMessage' => null, |
||
| 35 | 'paymentStatus' => null, |
||
| 36 | 'authCode' => null, |
||
| 37 | 'merchantData' => null, |
||
| 38 | ])); |
||
| 39 | |||
| 40 | 2 | $data = $response->getData(); |
|
| 41 | |||
| 42 | 2 | return new PaymentResponse( |
|
| 43 | 2 | $data['payId'], |
|
| 44 | 2 | DateTimeImmutable::createFromFormat('YmdHis', $data['dttm']), |
|
|
|
|||
| 45 | 2 | ResultCode::get($data['resultCode']), |
|
| 46 | 2 | $data['resultMessage'], |
|
| 47 | 2 | isset($data['paymentStatus']) ? PaymentStatus::get($data['paymentStatus']) : null, |
|
| 48 | 2 | $data['authCode'] ?? null, |
|
| 49 | 2 | isset($data['merchantData']) ? (string) base64_decode($data['merchantData'], true) : null |
|
| 50 | ); |
||
| 54 |