1 | <?php |
||
9 | class StkRequest |
||
10 | { |
||
11 | /** |
||
12 | * The amount to be deducted. |
||
13 | * |
||
14 | * @var int |
||
15 | */ |
||
16 | protected $amount; |
||
17 | /** |
||
18 | * The Mobile Subscriber Number. |
||
19 | * |
||
20 | * @var int |
||
21 | */ |
||
22 | protected $number; |
||
23 | /** |
||
24 | * The product reference identifier. |
||
25 | * |
||
26 | * @var int |
||
27 | */ |
||
28 | protected $referenceId; |
||
29 | /** |
||
30 | * The transaction handler. |
||
31 | * |
||
32 | * @var Transactor |
||
33 | */ |
||
34 | private $transactor; |
||
35 | |||
36 | /** |
||
37 | * Cashier constructor. |
||
38 | * |
||
39 | * @param Transactor $transactor |
||
40 | */ |
||
41 | public function __construct(Transactor $transactor) |
||
45 | |||
46 | /** |
||
47 | * Override the config pay bill number and pass key. |
||
48 | * |
||
49 | * @param $payBillNumber |
||
50 | * @param $payBillPassKey |
||
51 | * |
||
52 | * @return $this |
||
53 | */ |
||
54 | public function setPayBill($payBillNumber, $payBillPassKey) |
||
59 | |||
60 | /** |
||
61 | * Set the request amount to be deducted. |
||
62 | * |
||
63 | * @param int $amount |
||
64 | * |
||
65 | * @return $this |
||
66 | * @throws \InvalidArgumentException |
||
67 | */ |
||
68 | public function request($amount) |
||
76 | |||
77 | private function formatPhoneNumber(&$number) |
||
87 | |||
88 | /** |
||
89 | * Set the Mobile Subscriber Number to deduct the amount from. |
||
90 | * Must be in format 2547XXXXXXXX. |
||
91 | * |
||
92 | * @param int $number |
||
93 | * |
||
94 | * @return $this |
||
95 | * @throws \InvalidArgumentException |
||
96 | */ |
||
97 | public function from($number) |
||
106 | |||
107 | /** |
||
108 | * Set the product reference number to bill the account. |
||
109 | * |
||
110 | * @param int $referenceId |
||
111 | * |
||
112 | * @return $this |
||
113 | */ |
||
114 | public function usingReferenceId($referenceId) |
||
119 | |||
120 | /** |
||
121 | * Initiate the transaction |
||
122 | * |
||
123 | * @return mixed|\Psr\Http\Message\ResponseInterface |
||
124 | */ |
||
125 | public function transact() |
||
129 | |||
130 | /** |
||
131 | * Get payment status |
||
132 | * @return mixed |
||
133 | */ |
||
134 | public function status() |
||
143 | } |
||
144 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.