Passed
Push — main ( f00636...d89ccb )
by Pouya
02:03
created
src/Classes/Wallet.php 2 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 use Blockchain\Exception\CredentialsError;
12 12
 use Blockchain\Exception\ParameterError;
13 13
 
14
-class Wallet{
14
+class Wallet {
15 15
 
16 16
     protected $blockchain;
17 17
 
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      * Wallet constructor.
29 29
      * @param Blockchain $blockchain
30 30
      */
31
-    public function __construct(Blockchain $blockchain){
31
+    public function __construct(Blockchain $blockchain) {
32 32
         $this->blockchain = $blockchain;
33 33
     }
34 34
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      * @param $resource
39 39
      * @return string
40 40
      */
41
-    private function URL($resource){
41
+    private function URL($resource) {
42 42
         return 'merchant/'.$this->identifier.'/'.$resource;
43 43
     }
44 44
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      * @param string $guid
49 49
      * @param string $password
50 50
      */
51
-    public function credentials($guid, $password){
51
+    public function credentials($guid, $password) {
52 52
         $this->identifier = $guid;
53 53
         $this->password = $password;
54 54
     }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      * @throws CredentialsError
60 60
      */
61 61
     private function _checkCredentials() {
62
-        if(is_null($this->identifier) || is_null($this->password)) {
62
+        if (is_null($this->identifier) || is_null($this->password)) {
63 63
             throw new CredentialsError('Please enter wallet credentials.');
64 64
         }
65 65
     }
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      * @param array $extras
71 71
      * @return array
72 72
      */
73
-    private function reqParams($extras=array()) {
73
+    private function reqParams($extras = array()) {
74 74
         $ret = array('password'=>$this->password);
75 75
         return array_merge($ret, $extras);
76 76
     }
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      * @throws CredentialsError
83 83
      */
84 84
 
85
-    private function call($resource, $params=array()) {
85
+    private function call($resource, $params = array()) {
86 86
         $this->_checkCredentials();
87 87
         return $this->blockchain->Request('post', $this->URL($resource), $this->reqParams($params));
88 88
     }
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
      * @return AccountResponse
94 94
      */
95 95
 
96
-    public function CreateAddress($label = null){
96
+    public function CreateAddress($label = null) {
97 97
         $params = array();
98
-        if(!is_null($label))
98
+        if (!is_null($label))
99 99
             $params = ['label'=>$label];
100
-        $response = $this->call('accounts/create',$params);
100
+        $response = $this->call('accounts/create', $params);
101 101
         return new AccountResponse($response);
102 102
     }
103 103
 
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
      * @return int in satoshi
109 109
      */
110 110
 
111
-    public function Balance(){
111
+    public function Balance() {
112 112
         $response = $this->call('balance');
113 113
         return $response['balance'];
114 114
     }
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
      * @return int in satoshi
121 121
      */
122 122
 
123
-    public function AddressBallance($param){
123
+    public function AddressBallance($param) {
124 124
         $response = $this->call('accounts/'.$param.'/balance');
125 125
         return $response['balance'];
126 126
     }
@@ -130,10 +130,10 @@  discard block
 block discarded – undo
130 130
      * @return array<AccountResponse>
131 131
      */
132 132
 
133
-    public function ActiveAddresses(){
133
+    public function ActiveAddresses() {
134 134
         $addresses = $this->call('accounts');
135 135
         $response = array();
136
-        foreach ($addresses as $address){
136
+        foreach ($addresses as $address) {
137 137
             $response[] = new AccountResponse($address);
138 138
         }
139 139
         return $response;
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
      * @return array<string> xpub address
146 146
      */
147 147
 
148
-    public function XpubList(){
148
+    public function XpubList() {
149 149
         $response = $this->call('accounts/xpubs');
150 150
         return $response;
151 151
     }
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
      * @return AccountResponse
158 158
      */
159 159
 
160
-    public function SingleAddress($param){
160
+    public function SingleAddress($param) {
161 161
         $response = $this->call('accounts/'.$param);
162 162
         return new AccountResponse($response);
163 163
     }
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
      * @return string
170 170
      */
171 171
 
172
-    public function ReceivingAddress($param){
172
+    public function ReceivingAddress($param) {
173 173
         $response = $this->call('accounts/'.$param.'/receiveAddress');
174 174
         return $response['address'];
175 175
     }
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
      * @return AccountResponse
182 182
      */
183 183
 
184
-    public function ArchiveAddress($param){
184
+    public function ArchiveAddress($param) {
185 185
         $response = $this->call('accounts/'.$param.'/archive');
186 186
         return new AccountResponse($response);
187 187
     }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
      * @return AccountResponse
194 194
      */
195 195
 
196
-    public function UnArchiveAddress($param){
196
+    public function UnArchiveAddress($param) {
197 197
         $response = $this->call('accounts/'.$param.'/unarchive');
198 198
         return new AccountResponse($response);
199 199
     }
@@ -209,21 +209,21 @@  discard block
 block discarded – undo
209 209
      * @throws ParameterError
210 210
      */
211 211
 
212
-    public function SendPayment($to, $amount, $from=null, $fee=null, $fee_per_byte=null){
213
-        if(!isset($amount))
212
+    public function SendPayment($to, $amount, $from = null, $fee = null, $fee_per_byte = null) {
213
+        if (!isset($amount))
214 214
             throw new ParameterError("Amount required.");
215 215
 
216 216
         $params = array(
217 217
             'to'=>$to,
218 218
             'amount'=>$amount
219 219
         );
220
-        if(!is_null($from))
220
+        if (!is_null($from))
221 221
             $params['from'] = $from;
222
-        if(!is_null($fee))
222
+        if (!is_null($fee))
223 223
             $params['fee'] = $fee;
224
-        if(!is_null($fee_per_byte))
224
+        if (!is_null($fee_per_byte))
225 225
             $params['fee_per_byte'] = $fee_per_byte;
226
-        $response = $this->call('payment',$params);
226
+        $response = $this->call('payment', $params);
227 227
         return new PaymentResponse($response);
228 228
     }
229 229
 
@@ -236,17 +236,17 @@  discard block
 block discarded – undo
236 236
      * @param integer|null $fee_per_byte must be in satoshi
237 237
      */
238 238
 
239
-    public function SendManyPayment($recipients, $from=null, $fee=null, $fee_per_byte = null){
239
+    public function SendManyPayment($recipients, $from = null, $fee = null, $fee_per_byte = null) {
240 240
         $params = array(
241 241
             'recipients'=>json_encode($recipients)
242 242
         );
243
-        if(!is_null($from))
243
+        if (!is_null($from))
244 244
             $params['from'] = $from;
245
-        if(!is_null($fee))
245
+        if (!is_null($fee))
246 246
             $params['fee'] = $fee;
247
-        if(!is_null($fee_per_byte))
247
+        if (!is_null($fee_per_byte))
248 248
             $params['fee_per_byte'] = $fee_per_byte;
249
-        $response = $this->call('sendmany',$params);
249
+        $response = $this->call('sendmany', $params);
250 250
         return new PaymentResponse($response);
251 251
     }
252 252
 
Please login to merge, or discard this patch.
Braces   +24 added lines, -16 removed lines patch added patch discarded remove patch
@@ -95,8 +95,9 @@  discard block
 block discarded – undo
95 95
 
96 96
     public function CreateAddress($label = null){
97 97
         $params = array();
98
-        if(!is_null($label))
99
-            $params = ['label'=>$label];
98
+        if(!is_null($label)) {
99
+                    $params = ['label'=>$label];
100
+        }
100 101
         $response = $this->call('accounts/create',$params);
101 102
         return new AccountResponse($response);
102 103
     }
@@ -210,19 +211,23 @@  discard block
 block discarded – undo
210 211
      */
211 212
 
212 213
     public function SendPayment($to, $amount, $from=null, $fee=null, $fee_per_byte=null){
213
-        if(!isset($amount))
214
-            throw new ParameterError("Amount required.");
214
+        if(!isset($amount)) {
215
+                    throw new ParameterError("Amount required.");
216
+        }
215 217
 
216 218
         $params = array(
217 219
             'to'=>$to,
218 220
             'amount'=>$amount
219 221
         );
220
-        if(!is_null($from))
221
-            $params['from'] = $from;
222
-        if(!is_null($fee))
223
-            $params['fee'] = $fee;
224
-        if(!is_null($fee_per_byte))
225
-            $params['fee_per_byte'] = $fee_per_byte;
222
+        if(!is_null($from)) {
223
+                    $params['from'] = $from;
224
+        }
225
+        if(!is_null($fee)) {
226
+                    $params['fee'] = $fee;
227
+        }
228
+        if(!is_null($fee_per_byte)) {
229
+                    $params['fee_per_byte'] = $fee_per_byte;
230
+        }
226 231
         $response = $this->call('payment',$params);
227 232
         return new PaymentResponse($response);
228 233
     }
@@ -240,12 +245,15 @@  discard block
 block discarded – undo
240 245
         $params = array(
241 246
             'recipients'=>json_encode($recipients)
242 247
         );
243
-        if(!is_null($from))
244
-            $params['from'] = $from;
245
-        if(!is_null($fee))
246
-            $params['fee'] = $fee;
247
-        if(!is_null($fee_per_byte))
248
-            $params['fee_per_byte'] = $fee_per_byte;
248
+        if(!is_null($from)) {
249
+                    $params['from'] = $from;
250
+        }
251
+        if(!is_null($fee)) {
252
+                    $params['fee'] = $fee;
253
+        }
254
+        if(!is_null($fee_per_byte)) {
255
+                    $params['fee_per_byte'] = $fee_per_byte;
256
+        }
249 257
         $response = $this->call('sendmany',$params);
250 258
         return new PaymentResponse($response);
251 259
     }
Please login to merge, or discard this patch.
src/Blockchain.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 use GuzzleHttp\Client;
9 9
 use GuzzleHttp\Exception\GuzzleException;
10 10
 
11
-class Blockchain{
11
+class Blockchain {
12 12
 
13 13
     protected $client;
14 14
     protected $params;
@@ -16,29 +16,29 @@  discard block
 block discarded – undo
16 16
     const GET = 'GET';
17 17
     const POST = 'POST';
18 18
 
19
-    public function __construct($config){
20
-        $this->client = new Client(['base_uri'=>data_get($config,'base_uri')]);
21
-        $this->params['api_code'] = data_get('api_code',null);
19
+    public function __construct($config) {
20
+        $this->client = new Client(['base_uri'=>data_get($config, 'base_uri')]);
21
+        $this->params['api_code'] = data_get('api_code', null);
22 22
     }
23 23
 
24 24
     /**
25 25
      * @return Create
26 26
      */
27
-    public function Create(){
27
+    public function Create() {
28 28
         return new Create($this);
29 29
     }
30 30
 
31 31
     /**
32 32
      * @return Wallet
33 33
      */
34
-    public function Wallet(){
34
+    public function Wallet() {
35 35
         return new Wallet($this);
36 36
     }
37 37
 
38 38
     /**
39 39
      * @return Receive
40 40
      */
41
-    public function Receive(){
41
+    public function Receive() {
42 42
         return new Receive($this);
43 43
     }
44 44
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      * @param $base_uri string Default : http://localhost:3000
47 47
      */
48 48
 
49
-    public function newBaseUri($base_uri){
49
+    public function newBaseUri($base_uri) {
50 50
         $this->client = new Client(['base_uri'=>$base_uri]);
51 51
     }
52 52
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      * @return array
58 58
      */
59 59
 
60
-    public function Request($method, $url, $params){
60
+    public function Request($method, $url, $params) {
61 61
         $params = array_merge($this->params, $params);
62 62
         $options = array(
63 63
             'form-params'=>$params,
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         );
68 68
 
69 69
         try {
70
-            return json_decode($this->client->request($method, $url, $options)->getBody()->getContents(),true);
70
+            return json_decode($this->client->request($method, $url, $options)->getBody()->getContents(), true);
71 71
         } catch (GuzzleException $e) {
72 72
             //throw $e->getMessage();
73 73
         }
Please login to merge, or discard this patch.