Passed
Push — main ( d89ccb...0e1999 )
by Pouya
02:09
created
src/Objects/PaymentResponse.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 namespace Appino\Blockchain\Objects;
5 5
 
6 6
 
7
-class PaymentResponse{
7
+class PaymentResponse {
8 8
     /**
9 9
      * @var array of string
10 10
      */
@@ -35,19 +35,19 @@  discard block
 block discarded – undo
35 35
      * @param $json array
36 36
      */
37 37
 
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('success',$json))
50
-            $this->success = data_get($json,'success');
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('success', $json))
50
+            $this->success = data_get($json, 'success');
51 51
     }
52 52
 
53 53
 }
Please login to merge, or discard this patch.
Braces   +18 added lines, -12 removed lines patch added patch discarded remove patch
@@ -36,18 +36,24 @@
 block discarded – undo
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('success',$json))
50
-            $this->success = 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('success',$json)) {
55
+                    $this->success = data_get($json,'success');
56
+        }
51 57
     }
52 58
 
53 59
 }
Please login to merge, or discard this patch.
src/Classes/Create.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -5,12 +5,12 @@  discard block
 block discarded – undo
5 5
 use Appino\Blockchain\Exception\ParameterError;
6 6
 use Appino\Blockchain\Objects\WalletResponse;
7 7
 
8
-class Create{
8
+class Create {
9 9
 
10 10
     protected $blockchain;
11 11
     const URL = '/api/v2/create';
12 12
 
13
-    public function __construct(Blockchain $blockchain){
13
+    public function __construct(Blockchain $blockchain) {
14 14
         $this->blockchain = $blockchain;
15 15
     }
16 16
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      * @return WalletResponse
24 24
      * @throws ParameterError
25 25
      */
26
-    public function create($password, $email=null, $label=null) {
26
+    public function create($password, $email = null, $label = null) {
27 27
         return new WalletResponse($this->doCreate($password, null, $email, $label));
28 28
     }
29 29
 
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
      * @return WalletResponse
38 38
      * @throws ParameterError
39 39
      */
40
-    public function createWithKey($password, $privKey, $email=null, $label=null) {
41
-        if(!isset($privKey) || is_null($privKey))
40
+    public function createWithKey($password, $privKey, $email = null, $label = null) {
41
+        if (!isset($privKey) || is_null($privKey))
42 42
             throw new ParameterError("Private Key required.");
43 43
 
44 44
         return new WalletResponse($this->doCreate($password, $privKey, $email, $label));
@@ -54,21 +54,21 @@  discard block
 block discarded – undo
54 54
      * @return array
55 55
      * @throws ParameterError
56 56
      */
57
-    protected function doCreate($password, $priv = null, $label = null, $email = null){
58
-        if(!isset($password) || is_null($password))
57
+    protected function doCreate($password, $priv = null, $label = null, $email = null) {
58
+        if (!isset($password) || is_null($password))
59 59
             throw new ParameterError("Password required.");
60 60
 
61 61
         $params = array(
62 62
             'password'=>$password
63 63
         );
64
-        if(!is_null($priv))
64
+        if (!is_null($priv))
65 65
             $params['priv'] = $priv;
66
-        if(!is_null($email))
66
+        if (!is_null($email))
67 67
             $params['email'] = $email;
68
-        if(!is_null($label))
68
+        if (!is_null($label))
69 69
             $params['label'] = $label;
70 70
 
71
-        return $this->blockchain->Request(Blockchain::POST,self::URL,$params);
71
+        return $this->blockchain->Request(Blockchain::POST, self::URL, $params);
72 72
     }
73 73
 
74 74
 }
Please login to merge, or discard this patch.
src/Classes/Wallet.php 1 patch
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 Appino\Blockchain\Exception\CredentialsError;
12 12
 use Appino\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
     }
@@ -210,21 +210,21 @@  discard block
 block discarded – undo
210 210
      * @throws ParameterError
211 211
      */
212 212
 
213
-    public function SendPayment($to, $amount, $from=null, $fee=null, $fee_per_byte=null){
214
-        if(!isset($amount))
213
+    public function SendPayment($to, $amount, $from = null, $fee = null, $fee_per_byte = null) {
214
+        if (!isset($amount))
215 215
             throw new ParameterError("Amount required.");
216 216
 
217 217
         $params = array(
218 218
             'to'=>$to,
219 219
             'amount'=>$amount
220 220
         );
221
-        if(!is_null($from))
221
+        if (!is_null($from))
222 222
             $params['from'] = $from;
223
-        if(!is_null($fee))
223
+        if (!is_null($fee))
224 224
             $params['fee'] = $fee;
225
-        if(!is_null($fee_per_byte))
225
+        if (!is_null($fee_per_byte))
226 226
             $params['fee_per_byte'] = $fee_per_byte;
227
-        $response = $this->call('payment',$params);
227
+        $response = $this->call('payment', $params);
228 228
         return new PaymentResponse($response);
229 229
     }
230 230
 
@@ -237,17 +237,17 @@  discard block
 block discarded – undo
237 237
      * @param integer|null $fee_per_byte must be in satoshi
238 238
      */
239 239
 
240
-    public function SendManyPayment($recipients, $from=null, $fee=null, $fee_per_byte = null){
240
+    public function SendManyPayment($recipients, $from = null, $fee = null, $fee_per_byte = null) {
241 241
         $params = array(
242 242
             'recipients'=>json_encode($recipients)
243 243
         );
244
-        if(!is_null($from))
244
+        if (!is_null($from))
245 245
             $params['from'] = $from;
246
-        if(!is_null($fee))
246
+        if (!is_null($fee))
247 247
             $params['fee'] = $fee;
248
-        if(!is_null($fee_per_byte))
248
+        if (!is_null($fee_per_byte))
249 249
             $params['fee_per_byte'] = $fee_per_byte;
250
-        $response = $this->call('sendmany',$params);
250
+        $response = $this->call('sendmany', $params);
251 251
         return new PaymentResponse($response);
252 252
     }
253 253
 
Please login to merge, or discard this patch.
src/Classes/Receive.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -107,8 +107,8 @@
 block discarded – undo
107 107
      */
108 108
 
109 109
     public function DeleteBalanceNotification($id){
110
-       $response = json_decode($this->client->delete('balance_update/'.$id, ['query'=>$this->params])->getBody()->getContents(),true);
111
-       return $response['deleted'];
110
+        $response = json_decode($this->client->delete('balance_update/'.$id, ['query'=>$this->params])->getBody()->getContents(),true);
111
+        return $response['deleted'];
112 112
     }
113 113
 
114 114
     /**
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 use Appino\Blockchain\Objects\ReceiveResponse;
13 13
 use GuzzleHttp\Client;
14 14
 
15
-class Receive{
15
+class Receive {
16 16
 
17 17
     /**
18 18
      * @var array
@@ -25,19 +25,19 @@  discard block
 block discarded – undo
25 25
      * Receive constructor.
26 26
      */
27 27
 
28
-    public function __construct(){
28
+    public function __construct() {
29 29
         $this->client = new Client(['base_uri'=>self::URL]);
30 30
         $this->params = [
31
-            'key'=>data_get('api_code',null)
31
+            'key'=>data_get('api_code', null)
32 32
         ];
33 33
     }
34 34
 
35
-    private function Get($uri,$params=array()){
36
-        return $this->client->get($uri,['query'=>$params])->getBody()->getContents();
35
+    private function Get($uri, $params = array()) {
36
+        return $this->client->get($uri, ['query'=>$params])->getBody()->getContents();
37 37
     }
38 38
 
39
-    private function Post($uri,$params=array()){
40
-        return $this->client->post($uri,['form_params'=>$params])->getBody()->getContents();
39
+    private function Post($uri, $params = array()) {
40
+        return $this->client->post($uri, ['form_params'=>$params])->getBody()->getContents();
41 41
     }
42 42
 
43 43
     /**
@@ -48,14 +48,14 @@  discard block
 block discarded – undo
48 48
      * @param int $gap_limit How many unused addresses are allowed.
49 49
      * @return ReceiveResponse
50 50
      */
51
-    public function Generate($xpub, $callback, $gap_limit = 20){
51
+    public function Generate($xpub, $callback, $gap_limit = 20) {
52 52
         $params = [
53 53
             'xpub' => $xpub,
54 54
             'callback' => $callback,
55 55
             'gap_limit' => $gap_limit
56 56
         ];
57 57
         $params = array_merge($this->params, $params);
58
-        $response = json_decode($this->Get('',['query'=>$params]),true);
58
+        $response = json_decode($this->Get('', ['query'=>$params]), true);
59 59
         return new ReceiveResponse($response);
60 60
     }
61 61
 
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
      * @return integer
67 67
      * @throws \GuzzleHttp\Exception\GuzzleException
68 68
      */
69
-    public function AddressGap($xpub){
70
-        $params = array_merge(['xpub'=>$xpub],$this->params);
71
-        $response = json_decode($this->Get('checkgap',['query'=>$params]),true);
69
+    public function AddressGap($xpub) {
70
+        $params = array_merge(['xpub'=>$xpub], $this->params);
71
+        $response = json_decode($this->Get('checkgap', ['query'=>$params]), true);
72 72
         return $response['gap'];
73 73
     }
74 74
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      * @return NotificationResponse
86 86
      */
87 87
 
88
-    public function BalanceNotification($address, $callback, $on = Notification::KEEP, $confs = 3, $op = Operation::ALL){
88
+    public function BalanceNotification($address, $callback, $on = Notification::KEEP, $confs = 3, $op = Operation::ALL) {
89 89
         $params = [
90 90
             'address' => $address,
91 91
             'callback' => $callback,
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
             'op' => $op
95 95
         ];
96 96
         $params = array_merge($this->params, $params);
97
-        $response = json_decode($this->Post('balance_update',['form_params'=>$params]),true);
97
+        $response = json_decode($this->Post('balance_update', ['form_params'=>$params]), true);
98 98
         return new NotificationResponse($response);
99 99
     }
100 100
 
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
      * @throws \GuzzleHttp\Exception\GuzzleException
107 107
      */
108 108
 
109
-    public function DeleteBalanceNotification($id){
110
-       $response = json_decode($this->client->delete('balance_update/'.$id, ['query'=>$this->params])->getBody()->getContents(),true);
109
+    public function DeleteBalanceNotification($id) {
110
+       $response = json_decode($this->client->delete('balance_update/'.$id, ['query'=>$this->params])->getBody()->getContents(), true);
111 111
        return $response['deleted'];
112 112
     }
113 113
 
@@ -122,16 +122,16 @@  discard block
 block discarded – undo
122 122
      * @throws \GuzzleHttp\Exception\GuzzleException
123 123
      */
124 124
 
125
-    public function BlockNotification($callback, $on = Notification::KEEP, $confs = 1, $height = null){
125
+    public function BlockNotification($callback, $on = Notification::KEEP, $confs = 1, $height = null) {
126 126
         $params = [
127 127
             'callback' => $callback,
128 128
             'onNotification' => $on,
129 129
             'confs' => $confs,
130 130
         ];
131
-        if(!is_null($height))
131
+        if (!is_null($height))
132 132
             $params['height'] = $height;
133 133
         $params = array_merge($this->params, $params);
134
-        $response = json_decode($this->Post('block_notification',['form_params'=>$params]),true);
134
+        $response = json_decode($this->Post('block_notification', ['form_params'=>$params]), true);
135 135
         return new NotificationResponse($response);
136 136
     }
137 137
 
@@ -143,8 +143,8 @@  discard block
 block discarded – undo
143 143
      * @throws \GuzzleHttp\Exception\GuzzleException
144 144
      */
145 145
 
146
-    public function DeleteBlockNotification($id){
147
-        $response = json_decode($this->client->delete('block_notification/'.$id,['query'=>$this->params])->getBody()->getContents(),true);
146
+    public function DeleteBlockNotification($id) {
147
+        $response = json_decode($this->client->delete('block_notification/'.$id, ['query'=>$this->params])->getBody()->getContents(), true);
148 148
         return $response['deleted'];
149 149
     }
150 150
 
@@ -156,11 +156,11 @@  discard block
 block discarded – undo
156 156
      * @throws \GuzzleHttp\Exception\GuzzleException
157 157
      */
158 158
 
159
-    public function CallbackLogs($callback){
160
-        $params = array_merge(['callback'=>$callback],$this->params);
161
-        $logs = json_decode($this->Get('callback_log',['query'=>$params]),true);
159
+    public function CallbackLogs($callback) {
160
+        $params = array_merge(['callback'=>$callback], $this->params);
161
+        $logs = json_decode($this->Get('callback_log', ['query'=>$params]), true);
162 162
         $response = array();
163
-        foreach ($logs as $log){
163
+        foreach ($logs as $log) {
164 164
             $response[] = new LogResponse($log);
165 165
         }
166 166
         return $response;
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -128,8 +128,9 @@
 block discarded – undo
128 128
             'onNotification' => $on,
129 129
             'confs' => $confs,
130 130
         ];
131
-        if(!is_null($height))
132
-            $params['height'] = $height;
131
+        if(!is_null($height)) {
132
+                    $params['height'] = $height;
133
+        }
133 134
         $params = array_merge($this->params, $params);
134 135
         $response = json_decode($this->Post('block_notification',['form_params'=>$params]),true);
135 136
         return new NotificationResponse($response);
Please login to merge, or discard this patch.