1 | <?php |
||
13 | class TransactionBuilder |
||
14 | { |
||
15 | private $transaction; |
||
16 | |||
17 | private $amount; |
||
|
|||
18 | |||
19 | private $currency; |
||
20 | |||
21 | private $transactionInstance; |
||
22 | |||
23 | private $transactionId; |
||
24 | |||
25 | private $extraOptions = []; |
||
26 | |||
27 | private $description; |
||
28 | |||
29 | private $clientIp; |
||
30 | |||
31 | private $merchantReference; |
||
32 | |||
33 | private $constructArgs = []; |
||
34 | |||
35 | private $address = []; |
||
36 | |||
37 | private $customerEmail; |
||
38 | |||
39 | private static $saleMethods = [ |
||
40 | 'currency', |
||
41 | 'description', |
||
42 | 'clientIp', |
||
43 | 'address', |
||
44 | 'customerEmail', |
||
45 | ]; |
||
46 | |||
47 | 1 | private function __construct($transaction) |
|
51 | |||
52 | 1 | public static function purchase($amount) |
|
53 | { |
||
54 | $instance = new self('Larium\Pay\Transaction\PurchaseTransaction'); |
||
55 | 1 | $instance->constructArgs[] = $amount; |
|
56 | |||
57 | 1 | return $instance; |
|
58 | } |
||
59 | |||
60 | public static function authorize($amount) |
||
61 | { |
||
62 | $instance = new self('Larium\Pay\Transaction\AuthorizeTransaction'); |
||
63 | $instance->constructArgs[] = $amount; |
||
64 | |||
65 | return $instance; |
||
66 | } |
||
67 | |||
68 | public static function capture($amount) |
||
69 | { |
||
70 | $instance = new self('Larium\Pay\Transaction\CaptureTransaction'); |
||
71 | $instance->constructArgs[] = $amount; |
||
72 | |||
73 | return $instance; |
||
74 | } |
||
75 | |||
76 | public static function refund($amount) |
||
77 | { |
||
78 | $instance = new self('Larium\Pay\Transaction\RefundTransaction'); |
||
79 | $instance->constructArgs[] = $amount; |
||
80 | |||
81 | return $instance; |
||
82 | } |
||
83 | |||
84 | public static function cancel($transactionId) |
||
85 | { |
||
86 | $instance = new self('Larium\Pay\Transaction\CancelTransaction'); |
||
87 | $instance->constructArgs[] = $transactionId; |
||
88 | |||
89 | return $instance; |
||
90 | } |
||
91 | |||
92 | 1 | public function charge(CreditCard $card) |
|
93 | { |
||
94 | 1 | $this->constructArgs[] = $card; |
|
95 | |||
96 | 1 | return $this; |
|
97 | 1 | } |
|
98 | |||
99 | 1 | public function with($currency) |
|
105 | |||
106 | 1 | public function withExtraOptions(array $extraOptions) |
|
107 | { |
||
108 | 1 | $this->extraOptions = $extraOptions; |
|
109 | |||
110 | 1 | return $this; |
|
111 | 1 | } |
|
112 | |||
113 | 1 | public function describedAs($description) |
|
119 | |||
120 | 1 | public function billTo(array $address) |
|
121 | { |
||
122 | 1 | $this->address = $address; |
|
123 | |||
124 | 1 | return $this; |
|
125 | 1 | } |
|
126 | |||
127 | 1 | public function mailTo($customerEmail) |
|
133 | |||
134 | public function withMerchantReference($merchantReference) |
||
135 | { |
||
136 | $this->merchantReference = $merchantReference; |
||
137 | |||
138 | return $this; |
||
139 | } |
||
140 | |||
141 | 1 | public function withClientIp($clientIp) |
|
147 | |||
148 | 1 | public function getTransaction() |
|
149 | { |
||
150 | $this->build(); |
||
151 | |||
152 | 1 | return $this->transactionInstance; |
|
153 | } |
||
154 | |||
155 | 1 | private function build() |
|
156 | { |
||
157 | $reflection = new ReflectionClass($this->transaction); |
||
171 | } |
||
172 |
This check marks private properties in classes that are never used. Those properties can be removed.