Conditions | 3 |
Paths | 4 |
Total Lines | 22 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
34 | 4 | public function handle(string $reference) : array |
|
35 | { |
||
36 | 4 | $link = $this->baseUrl . self::TRANSACTION_VERIFICATION . $reference; |
|
37 | |||
38 | 4 | $response = $this->verifyTransaction($link); |
|
39 | |||
40 | 4 | $this->verifyResponse($response); |
|
41 | |||
42 | 3 | $result = json_decode($response->getBody(), true); |
|
43 | |||
44 | 3 | $validated = false; |
|
45 | |||
46 | 3 | if (strcmp($result['message'], self::VERIFIED_TRANSACTION) === 0) { |
|
47 | 2 | $validated = true; |
|
48 | } |
||
49 | |||
50 | 3 | if (false === $validated) { |
|
51 | 1 | throw new TransactionVerficationFailedException(self::INVALID_TRANSACTION); |
|
52 | } |
||
53 | |||
54 | 2 | return $result["data"]; |
|
55 | } |
||
56 | |||
67 |