@@ -56,26 +56,36 @@ |
||
56 | 56 | */ |
57 | 57 | |
58 | 58 | public function __construct($json){ |
59 | - if(array_key_exists('balance',$json)) |
|
60 | - $this->balance = data_get($json,'balance'); |
|
61 | - if(array_key_exists('address',$json)) |
|
62 | - $this->label = data_get($json,'address'); |
|
63 | - if(array_key_exists('label',$json)) |
|
64 | - $this->index = data_get($json,'label'); |
|
65 | - if(array_key_exists('archived',$json)) |
|
66 | - $this->archived = data_get($json,'archived'); |
|
67 | - if(array_key_exists('extendedPublicKey',$json)) |
|
68 | - $this->extendedPublicKey = data_get($json,'extendedPublicKey'); |
|
69 | - if(array_key_exists('extendedPrivateKey',$json)) |
|
70 | - $this->extendedPrivateKey = data_get($json,'extendedPrivateKey'); |
|
71 | - if(array_key_exists('receiveIndex',$json)) |
|
72 | - $this->receiveIndex = data_get($json,'receiveIndex'); |
|
73 | - if(array_key_exists('lastUsedReceiveIndex',$json)) |
|
74 | - $this->lastUsedReceiveIndex = data_get($json,'lastUsedReceiveIndex'); |
|
75 | - if(array_key_exists('receiveAddress',$json)) |
|
76 | - $this->receiveAddress = data_get($json,'receiveAddress'); |
|
77 | - if(array_key_exists('cache',$json)) |
|
78 | - $this->cahce = new Cache(data_get($json,'cache')); |
|
59 | + if(array_key_exists('balance',$json)) { |
|
60 | + $this->balance = data_get($json,'balance'); |
|
61 | + } |
|
62 | + if(array_key_exists('address',$json)) { |
|
63 | + $this->label = data_get($json,'address'); |
|
64 | + } |
|
65 | + if(array_key_exists('label',$json)) { |
|
66 | + $this->index = data_get($json,'label'); |
|
67 | + } |
|
68 | + if(array_key_exists('archived',$json)) { |
|
69 | + $this->archived = data_get($json,'archived'); |
|
70 | + } |
|
71 | + if(array_key_exists('extendedPublicKey',$json)) { |
|
72 | + $this->extendedPublicKey = data_get($json,'extendedPublicKey'); |
|
73 | + } |
|
74 | + if(array_key_exists('extendedPrivateKey',$json)) { |
|
75 | + $this->extendedPrivateKey = data_get($json,'extendedPrivateKey'); |
|
76 | + } |
|
77 | + if(array_key_exists('receiveIndex',$json)) { |
|
78 | + $this->receiveIndex = data_get($json,'receiveIndex'); |
|
79 | + } |
|
80 | + if(array_key_exists('lastUsedReceiveIndex',$json)) { |
|
81 | + $this->lastUsedReceiveIndex = data_get($json,'lastUsedReceiveIndex'); |
|
82 | + } |
|
83 | + if(array_key_exists('receiveAddress',$json)) { |
|
84 | + $this->receiveAddress = data_get($json,'receiveAddress'); |
|
85 | + } |
|
86 | + if(array_key_exists('cache',$json)) { |
|
87 | + $this->cahce = new Cache(data_get($json,'cache')); |
|
88 | + } |
|
79 | 89 | } |
80 | 90 | |
81 | 91 | } |
@@ -19,12 +19,15 @@ |
||
19 | 19 | public $callback; |
20 | 20 | |
21 | 21 | public function __construct($json){ |
22 | - if(array_key_exists('address',$json)) |
|
23 | - $this->address = data_get($json,'address'); |
|
24 | - if(array_key_exists('index',$json)) |
|
25 | - $this->index = data_get($json,'index'); |
|
26 | - if(array_key_exists('callback',$json)) |
|
27 | - $this->callback = data_get($json,'callback'); |
|
22 | + if(array_key_exists('address',$json)) { |
|
23 | + $this->address = data_get($json,'address'); |
|
24 | + } |
|
25 | + if(array_key_exists('index',$json)) { |
|
26 | + $this->index = data_get($json,'index'); |
|
27 | + } |
|
28 | + if(array_key_exists('callback',$json)) { |
|
29 | + $this->callback = data_get($json,'callback'); |
|
30 | + } |
|
28 | 31 | } |
29 | 32 | |
30 | 33 | } |
@@ -23,12 +23,15 @@ |
||
23 | 23 | */ |
24 | 24 | |
25 | 25 | public function __construct($json){ |
26 | - if(array_key_exists('guid',$json)) |
|
27 | - $this->guid = data_get($json,'balance'); |
|
28 | - if(array_key_exists('address',$json)) |
|
29 | - $this->address = data_get($json,'address'); |
|
30 | - if(array_key_exists('label',$json)) |
|
31 | - $this->label = data_get($json,'label'); |
|
26 | + if(array_key_exists('guid',$json)) { |
|
27 | + $this->guid = data_get($json,'balance'); |
|
28 | + } |
|
29 | + if(array_key_exists('address',$json)) { |
|
30 | + $this->address = data_get($json,'address'); |
|
31 | + } |
|
32 | + if(array_key_exists('label',$json)) { |
|
33 | + $this->label = data_get($json,'label'); |
|
34 | + } |
|
32 | 35 | } |
33 | 36 | |
34 | 37 | } |
@@ -36,18 +36,24 @@ |
||
36 | 36 | */ |
37 | 37 | |
38 | 38 | public function __construct($json){ |
39 | - if(array_key_exists('to',$json)) |
|
40 | - $this->to = data_get($json,'to'); |
|
41 | - if(array_key_exists('from',$json)) |
|
42 | - $this->from = data_get($json,'from'); |
|
43 | - if(array_key_exists('amount',$json)) |
|
44 | - $this->amount = data_get($json,'amount'); |
|
45 | - if(array_key_exists('fee',$json)) |
|
46 | - $this->fee = data_get($json,'fee'); |
|
47 | - if(array_key_exists('txid',$json)) |
|
48 | - $this->txid = data_get($json,'txid'); |
|
49 | - if(array_key_exists('succevss',$json)) |
|
50 | - $this->succevss = data_get($json,'success'); |
|
39 | + if(array_key_exists('to',$json)) { |
|
40 | + $this->to = data_get($json,'to'); |
|
41 | + } |
|
42 | + if(array_key_exists('from',$json)) { |
|
43 | + $this->from = data_get($json,'from'); |
|
44 | + } |
|
45 | + if(array_key_exists('amount',$json)) { |
|
46 | + $this->amount = data_get($json,'amount'); |
|
47 | + } |
|
48 | + if(array_key_exists('fee',$json)) { |
|
49 | + $this->fee = data_get($json,'fee'); |
|
50 | + } |
|
51 | + if(array_key_exists('txid',$json)) { |
|
52 | + $this->txid = data_get($json,'txid'); |
|
53 | + } |
|
54 | + if(array_key_exists('succevss',$json)) { |
|
55 | + $this->succevss = data_get($json,'success'); |
|
56 | + } |
|
51 | 57 | } |
52 | 58 | |
53 | 59 | } |
@@ -24,14 +24,18 @@ |
||
24 | 24 | public $response_code; |
25 | 25 | |
26 | 26 | public function __construct($json){ |
27 | - if(array_key_exists('callback',$json)) |
|
28 | - $this->callback = data_get($json,'callback'); |
|
29 | - if(array_key_exists('called_at',$json)) |
|
30 | - $this->called_at = data_get($json,'called_at'); |
|
31 | - if(array_key_exists('raw_response',$json)) |
|
32 | - $this->raw_response = data_get($json,'raw_response'); |
|
33 | - if(array_key_exists('response_code',$json)) |
|
34 | - $this->response_code = data_get($json,'response_code'); |
|
27 | + if(array_key_exists('callback',$json)) { |
|
28 | + $this->callback = data_get($json,'callback'); |
|
29 | + } |
|
30 | + if(array_key_exists('called_at',$json)) { |
|
31 | + $this->called_at = data_get($json,'called_at'); |
|
32 | + } |
|
33 | + if(array_key_exists('raw_response',$json)) { |
|
34 | + $this->raw_response = data_get($json,'raw_response'); |
|
35 | + } |
|
36 | + if(array_key_exists('response_code',$json)) { |
|
37 | + $this->response_code = data_get($json,'response_code'); |
|
38 | + } |
|
35 | 39 | } |
36 | 40 | |
37 | 41 | } |
@@ -124,8 +124,9 @@ |
||
124 | 124 | 'onNotification' => $on, |
125 | 125 | 'confs' => $confs, |
126 | 126 | ]; |
127 | - if(!is_null($height)) |
|
128 | - $params['height'] = $height; |
|
127 | + if(!is_null($height)) { |
|
128 | + $params['height'] = $height; |
|
129 | + } |
|
129 | 130 | $params = array_merge($this->params, $params); |
130 | 131 | $response = json_decode($this->client->post('block_notification',['form_params'=>$params]),true); |
131 | 132 | return new NotificationResponse($response); |
@@ -192,19 +192,23 @@ discard block |
||
192 | 192 | */ |
193 | 193 | |
194 | 194 | public function SendPayment($to, $amount, $from=null, $fee=null, $fee_per_byte=null){ |
195 | - if(!isset($amount)) |
|
196 | - throw new ParameterError("Amount required."); |
|
195 | + if(!isset($amount)) { |
|
196 | + throw new ParameterError("Amount required."); |
|
197 | + } |
|
197 | 198 | |
198 | 199 | $params = array( |
199 | 200 | 'to'=>$to, |
200 | 201 | 'amount'=>$amount |
201 | 202 | ); |
202 | - if(!is_null($from)) |
|
203 | - $params['from'] = $from; |
|
204 | - if(!is_null($fee)) |
|
205 | - $params['fee'] = $fee; |
|
206 | - if(!is_null($fee_per_byte)) |
|
207 | - $params['fee_per_byte'] = $fee_per_byte; |
|
203 | + if(!is_null($from)) { |
|
204 | + $params['from'] = $from; |
|
205 | + } |
|
206 | + if(!is_null($fee)) { |
|
207 | + $params['fee'] = $fee; |
|
208 | + } |
|
209 | + if(!is_null($fee_per_byte)) { |
|
210 | + $params['fee_per_byte'] = $fee_per_byte; |
|
211 | + } |
|
208 | 212 | $response = $this->call('payment',$params); |
209 | 213 | return new PaymentResponse($response); |
210 | 214 | } |
@@ -222,12 +226,15 @@ discard block |
||
222 | 226 | $params = array( |
223 | 227 | 'recipients'=>json_encode($recipients) |
224 | 228 | ); |
225 | - if(!is_null($from)) |
|
226 | - $params['from'] = $from; |
|
227 | - if(!is_null($fee)) |
|
228 | - $params['fee'] = $fee; |
|
229 | - if(!is_null($fee_per_byte)) |
|
230 | - $params['fee_per_byte'] = $fee_per_byte; |
|
229 | + if(!is_null($from)) { |
|
230 | + $params['from'] = $from; |
|
231 | + } |
|
232 | + if(!is_null($fee)) { |
|
233 | + $params['fee'] = $fee; |
|
234 | + } |
|
235 | + if(!is_null($fee_per_byte)) { |
|
236 | + $params['fee_per_byte'] = $fee_per_byte; |
|
237 | + } |
|
231 | 238 | $response = $this->call('sendmany',$params); |
232 | 239 | return new PaymentResponse($response); |
233 | 240 | } |
@@ -38,8 +38,9 @@ discard block |
||
38 | 38 | * @throws ParameterError |
39 | 39 | */ |
40 | 40 | public function createWithKey($password, $privKey, $email=null, $label=null) { |
41 | - if(!isset($privKey) || is_null($privKey)) |
|
42 | - throw new ParameterError("Private Key required."); |
|
41 | + if(!isset($privKey) || is_null($privKey)) { |
|
42 | + throw new ParameterError("Private Key required."); |
|
43 | + } |
|
43 | 44 | |
44 | 45 | return new WalletResponse($this->doCreate($password, $privKey, $email, $label)); |
45 | 46 | } |
@@ -55,18 +56,22 @@ discard block |
||
55 | 56 | * @throws ParameterError |
56 | 57 | */ |
57 | 58 | protected function doCreate($password, $priv = null, $label = null, $email = null){ |
58 | - if(!isset($password) || is_null($password)) |
|
59 | - throw new ParameterError("Password required."); |
|
59 | + if(!isset($password) || is_null($password)) { |
|
60 | + throw new ParameterError("Password required."); |
|
61 | + } |
|
60 | 62 | |
61 | 63 | $params = array( |
62 | 64 | 'password'=>$password |
63 | 65 | ); |
64 | - if(!is_null($priv)) |
|
65 | - $params['priv'] = $priv; |
|
66 | - if(!is_null($email)) |
|
67 | - $params['email'] = $email; |
|
68 | - if(!is_null($label)) |
|
69 | - $params['label'] = $label; |
|
66 | + if(!is_null($priv)) { |
|
67 | + $params['priv'] = $priv; |
|
68 | + } |
|
69 | + if(!is_null($email)) { |
|
70 | + $params['email'] = $email; |
|
71 | + } |
|
72 | + if(!is_null($label)) { |
|
73 | + $params['label'] = $label; |
|
74 | + } |
|
70 | 75 | |
71 | 76 | return $this->blockchain->Request(Blockchain::POST,self::URL,$params); |
72 | 77 | } |