Browse Source

make some property optional

tags/2.0
0nepeop1e 4 years ago
parent
commit
cc5b67361a
2 changed files with 14 additions and 11 deletions
  1. 5
    5
      src/Contracts/PaymentGatewayDriver.php
  2. 9
    6
      src/Traits/BillStatusBoolean.php

+ 5
- 5
src/Contracts/PaymentGatewayDriver.php View File

15
 
15
 
16
     public function verifyGatewayCallback(Request $request, Response &$response = null): bool;
16
     public function verifyGatewayCallback(Request $request, Response &$response = null): bool;
17
 
17
 
18
-    public function getBillIdFromRequest(Request $request): string;
18
+    public function getBillIdFromRequest(Request $request): ?string;
19
 
19
 
20
-    public function getBillStatus(Request $request): int;
20
+    public function getBillStatus(Request $request): ?int;
21
 
21
 
22
-    public function isBillSuccess(Request $request): bool;
22
+    public function isBillSuccess(Request $request): ?bool;
23
 
23
 
24
-    public function isBillFailed(Request $request): bool;
24
+    public function isBillFailed(Request $request): ?bool;
25
 
25
 
26
-    public function isBillPending(Request $request): bool;
26
+    public function isBillPending(Request $request): ?bool;
27
 }
27
 }

+ 9
- 6
src/Traits/BillStatusBoolean.php View File

8
 
8
 
9
 trait BillStatusBoolean
9
 trait BillStatusBoolean
10
 {
10
 {
11
-    public function isBillSuccess(Request $request): bool
11
+    public function isBillSuccess(Request $request): ?bool
12
     {
12
     {
13
-        return $this->getBillStatus($request) > 0;
13
+        $status = $this->getBillStatus($request);
14
+        return $status === null ? null : $status > 0;
14
     }
15
     }
15
 
16
 
16
-    public function isBillFailed(Request $request): bool
17
+    public function isBillFailed(Request $request): ?bool
17
     {
18
     {
18
-        return $this->getBillStatus($request) < 0;
19
+        $status = $this->getBillStatus($request);
20
+        return $status === null ? null : $status < 0;
19
     }
21
     }
20
 
22
 
21
-    public function isBillPending(Request $request): bool
23
+    public function isBillPending(Request $request): ?bool
22
     {
24
     {
23
-        return $this->getBillStatus($request) == 0;
25
+        $status = $this->getBillStatus($request);
26
+        return $status === null ? null : $status == 0;
24
     }
27
     }
25
 }
28
 }

Loading…
Cancel
Save