@@ -50,8 +50,9 @@ |
||
| 50 | 50 | |
| 51 | 51 | public function __construct($params){ |
| 52 | 52 | //echo Json::encode($params); |
| 53 | - if(is_null($params)) |
|
| 54 | - return; |
|
| 53 | + if(is_null($params)) { |
|
| 54 | + return; |
|
| 55 | + } |
|
| 55 | 56 | $this->balance = data_get($params,'balance'); |
| 56 | 57 | $this->label = data_get($params,'label'); |
| 57 | 58 | $this->index = data_get($params,'index'); |
@@ -38,8 +38,9 @@ |
||
| 38 | 38 | |
| 39 | 39 | public function __construct($params){ |
| 40 | 40 | //echo Json::encode($params); |
| 41 | - if(is_null($params)) |
|
| 42 | - return; |
|
| 41 | + if(is_null($params)) { |
|
| 42 | + return; |
|
| 43 | + } |
|
| 43 | 44 | $this->label = data_get($params,'label'); |
| 44 | 45 | $this->archived = data_get($params,'archived'); |
| 45 | 46 | $this->xpriv = data_get($params,'xpriv'); |
@@ -26,8 +26,9 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | |
| 28 | 28 | public function __construct($params){ |
| 29 | - if(is_null($params)) |
|
| 30 | - return; |
|
| 29 | + if(is_null($params)) { |
|
| 30 | + return; |
|
| 31 | + } |
|
| 31 | 32 | $this->guid = data_get($params,'guid'); |
| 32 | 33 | $this->address = data_get($params,'address'); |
| 33 | 34 | $this->label = data_get($params,'label'); |
@@ -12,8 +12,9 @@ |
||
| 12 | 12 | public $changeAccount; |
| 13 | 13 | |
| 14 | 14 | public function __construct($params){ |
| 15 | - if(is_null($params)) |
|
| 16 | - return; |
|
| 15 | + if(is_null($params)) { |
|
| 16 | + return; |
|
| 17 | + } |
|
| 17 | 18 | $this->receiveAccount = data_get($params,'receiveAccount'); |
| 18 | 19 | $this->changeAccount = data_get($params,'changeAccount'); |
| 19 | 20 | } |
@@ -84,8 +84,9 @@ |
||
| 84 | 84 | if(is_null($json)) { |
| 85 | 85 | // this is possibly a from btc request with a comma separation |
| 86 | 86 | $json = json_decode(str_replace(',', '', $response)); |
| 87 | - if (is_null($json)) |
|
| 88 | - throw new Error("Unable to decode JSON response from Blockchain: " . $response->getBody()->getContents()); |
|
| 87 | + if (is_null($json)) { |
|
| 88 | + throw new Error("Unable to decode JSON response from Blockchain: " . $response->getBody()->getContents()); |
|
| 89 | + } |
|
| 89 | 90 | } |
| 90 | 91 | if(array_key_exists('error', $json)) { |
| 91 | 92 | throw new ApiError($json['error']); |
@@ -39,8 +39,9 @@ discard block |
||
| 39 | 39 | * @throws ParameterError |
| 40 | 40 | */ |
| 41 | 41 | public function createWithKey($password, $privKey, $email=null, $label=null) { |
| 42 | - if(!isset($privKey) || is_null($privKey)) |
|
| 43 | - throw new ParameterError("Private Key required."); |
|
| 42 | + if(!isset($privKey) || is_null($privKey)) { |
|
| 43 | + throw new ParameterError("Private Key required."); |
|
| 44 | + } |
|
| 44 | 45 | |
| 45 | 46 | return new WalletResponse($this->doCreate($password, $privKey, $email, $label)); |
| 46 | 47 | } |
@@ -56,19 +57,23 @@ discard block |
||
| 56 | 57 | * @throws ParameterError |
| 57 | 58 | */ |
| 58 | 59 | protected function doCreate($password, $priv = null, $label = null, $email = null){ |
| 59 | - if(!isset($password) || empty($password)) |
|
| 60 | - throw new ParameterError("Password required."); |
|
| 60 | + if(!isset($password) || empty($password)) { |
|
| 61 | + throw new ParameterError("Password required."); |
|
| 62 | + } |
|
| 61 | 63 | |
| 62 | 64 | $params = array( |
| 63 | 65 | 'password'=>$password, |
| 64 | 66 | 'hd'=>true |
| 65 | 67 | ); |
| 66 | - if(!is_null($priv)) |
|
| 67 | - $params['priv'] = $priv; |
|
| 68 | - if(!is_null($email)) |
|
| 69 | - $params['email'] = $email; |
|
| 70 | - if(!is_null($label)) |
|
| 71 | - $params['label'] = $label; |
|
| 68 | + if(!is_null($priv)) { |
|
| 69 | + $params['priv'] = $priv; |
|
| 70 | + } |
|
| 71 | + if(!is_null($email)) { |
|
| 72 | + $params['email'] = $email; |
|
| 73 | + } |
|
| 74 | + if(!is_null($label)) { |
|
| 75 | + $params['label'] = $label; |
|
| 76 | + } |
|
| 72 | 77 | |
| 73 | 78 | return $this->blockchain->Request(Blockchain::POST,self::URL,$params); |
| 74 | 79 | } |
@@ -97,8 +97,9 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | public function CreateAddress($label = null){ |
| 99 | 99 | $params = array(); |
| 100 | - if(!is_null($label)) |
|
| 101 | - $params = ['label'=>$label]; |
|
| 100 | + if(!is_null($label)) { |
|
| 101 | + $params = ['label'=>$label]; |
|
| 102 | + } |
|
| 102 | 103 | $response = $this->call('accounts/create',$params); |
| 103 | 104 | return new WalletAddress($response); |
| 104 | 105 | } |
@@ -135,9 +136,10 @@ discard block |
||
| 135 | 136 | public function ActiveAddresses() { |
| 136 | 137 | $addresses = $this->call('accounts',$this->reqParams()); |
| 137 | 138 | $response = array(); |
| 138 | - if(!is_null($addresses)) |
|
| 139 | - foreach ($addresses as $address){ |
|
| 139 | + if(!is_null($addresses)) { |
|
| 140 | + foreach ($addresses as $address){ |
|
| 140 | 141 | $response[] = new AccountResponse($address); |
| 142 | + } |
|
| 141 | 143 | } |
| 142 | 144 | return $response; |
| 143 | 145 | } |
@@ -214,19 +216,23 @@ discard block |
||
| 214 | 216 | */ |
| 215 | 217 | |
| 216 | 218 | public function SendPayment($to, $amount, $from=null, $fee=null, $fee_per_byte=null){ |
| 217 | - if(!isset($amount)) |
|
| 218 | - throw new ParameterError("Amount required."); |
|
| 219 | + if(!isset($amount)) { |
|
| 220 | + throw new ParameterError("Amount required."); |
|
| 221 | + } |
|
| 219 | 222 | |
| 220 | 223 | $params = array( |
| 221 | 224 | 'to'=>$to, |
| 222 | 225 | 'amount'=>$amount |
| 223 | 226 | ); |
| 224 | - if(!is_null($from)) |
|
| 225 | - $params['from'] = $from; |
|
| 226 | - if(!is_null($fee)) |
|
| 227 | - $params['fee'] = $fee; |
|
| 228 | - if(!is_null($fee_per_byte)) |
|
| 229 | - $params['fee_per_byte'] = $fee_per_byte; |
|
| 227 | + if(!is_null($from)) { |
|
| 228 | + $params['from'] = $from; |
|
| 229 | + } |
|
| 230 | + if(!is_null($fee)) { |
|
| 231 | + $params['fee'] = $fee; |
|
| 232 | + } |
|
| 233 | + if(!is_null($fee_per_byte)) { |
|
| 234 | + $params['fee_per_byte'] = $fee_per_byte; |
|
| 235 | + } |
|
| 230 | 236 | $response = $this->call('payment',$params); |
| 231 | 237 | return new PaymentResponse($response); |
| 232 | 238 | } |
@@ -244,12 +250,15 @@ discard block |
||
| 244 | 250 | $params = array( |
| 245 | 251 | 'recipients'=>json_encode($recipients) |
| 246 | 252 | ); |
| 247 | - if(!is_null($from)) |
|
| 248 | - $params['from'] = $from; |
|
| 249 | - if(!is_null($fee)) |
|
| 250 | - $params['fee'] = $fee; |
|
| 251 | - if(!is_null($fee_per_byte)) |
|
| 252 | - $params['fee_per_byte'] = $fee_per_byte; |
|
| 253 | + if(!is_null($from)) { |
|
| 254 | + $params['from'] = $from; |
|
| 255 | + } |
|
| 256 | + if(!is_null($fee)) { |
|
| 257 | + $params['fee'] = $fee; |
|
| 258 | + } |
|
| 259 | + if(!is_null($fee_per_byte)) { |
|
| 260 | + $params['fee_per_byte'] = $fee_per_byte; |
|
| 261 | + } |
|
| 253 | 262 | $response = $this->call('sendmany',$params); |
| 254 | 263 | return new PaymentResponse($response); |
| 255 | 264 | } |
@@ -142,8 +142,9 @@ |
||
| 142 | 142 | 'onNotification' => $on, |
| 143 | 143 | 'confs' => $confs, |
| 144 | 144 | ]; |
| 145 | - if(!is_null($height)) |
|
| 146 | - $params['height'] = $height; |
|
| 145 | + if(!is_null($height)) { |
|
| 146 | + $params['height'] = $height; |
|
| 147 | + } |
|
| 147 | 148 | $params = array_merge($this->params, $params); |
| 148 | 149 | $response = $this->call('POST','block_notification',$params); |
| 149 | 150 | return new NotificationResponse($response); |