Skip to content

Commit 6b65f57

Browse files
committed
Refactor handling of response properties with null checks
1 parent 3902a6e commit 6b65f57

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/ValueObjects/PaystackVerificationResponse.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ public function __construct(
2020
public static function from(\stdClass $paystackResponse)
2121
{
2222
return new self(
23-
status: $paystackResponse->status,
24-
message: $paystackResponse->message,
25-
data: collect($paystackResponse->data)
23+
status: $paystackResponse->status ?? null,
24+
message: $paystackResponse->message ?? null,
25+
data: collect($paystackResponse->data ?? null)
2626
->only(['status', 'amount', 'gateway_response', 'created_at', 'metadata'])
2727
->toArray(),
2828
);

src/ValueObjects/RemitaResponse.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public function __construct(
1818
public static function from(\stdClass $rrrQueryResponse)
1919
{
2020
return new self(
21-
paymentDate: $rrrQueryResponse->paymentDate,
22-
status: $rrrQueryResponse->status,
23-
amount: $rrrQueryResponse->amount,
21+
paymentDate: $rrrQueryResponse->paymentDate ?? null,
22+
status: $rrrQueryResponse->status ?? null,
23+
amount: $rrrQueryResponse->amount ?? null,
2424
);
2525
}
2626
}

0 commit comments

Comments
 (0)