Passed
Push — main ( cd1286...7e00d3 )
by Pouya
02:15
created
src/Classes/Wallet.php 1 patch
Spacing   +27 added lines, -27 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
     }
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
      * @return int in satoshi
95 95
      */
96 96
 
97
-    public function Balance(){
97
+    public function Balance() {
98 98
         $response = $this->call('balance');
99 99
         return $response['balance'];
100 100
     }
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
      * @return int in satoshi
107 107
      */
108 108
 
109
-    public function AddressBallance($param){
109
+    public function AddressBallance($param) {
110 110
         $response = $this->call('accounts/'.$param.'/balance');
111 111
         return $response['balance'];
112 112
     }
@@ -116,10 +116,10 @@  discard block
 block discarded – undo
116 116
      * @return array<AccountResponse>
117 117
      */
118 118
 
119
-    public function ActiveAddresses(){
119
+    public function ActiveAddresses() {
120 120
         $addresses = $this->call('accounts');
121 121
         $response = array();
122
-        foreach ($addresses as $address){
122
+        foreach ($addresses as $address) {
123 123
             $response[] = new AccountResponse($address);
124 124
         }
125 125
         return $response;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
      * @return array<string> xpub address
132 132
      */
133 133
 
134
-    public function XpubList(){
134
+    public function XpubList() {
135 135
         $response = $this->call('accounts/xpubs');
136 136
         return $response;
137 137
     }
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
      * @return AccountResponse
144 144
      */
145 145
 
146
-    public function SingleAddress($param){
146
+    public function SingleAddress($param) {
147 147
         $response = $this->call('accounts/'.$param);
148 148
         return new AccountResponse($response);
149 149
     }
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
      * @return string
156 156
      */
157 157
 
158
-    public function ReceivingAddress($param){
158
+    public function ReceivingAddress($param) {
159 159
         $response = $this->call('accounts/'.$param.'/receiveAddress');
160 160
         return $response['address'];
161 161
     }
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
      * @return AccountResponse
168 168
      */
169 169
 
170
-    public function ArchiveAddress($param){
170
+    public function ArchiveAddress($param) {
171 171
         $response = $this->call('accounts/'.$param.'/archive');
172 172
         return new AccountResponse($response);
173 173
     }
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
      * @return AccountResponse
180 180
      */
181 181
 
182
-    public function UnArchiveAddress($param){
182
+    public function UnArchiveAddress($param) {
183 183
         $response = $this->call('accounts/'.$param.'/unarchive');
184 184
         return new AccountResponse($response);
185 185
     }
@@ -195,21 +195,21 @@  discard block
 block discarded – undo
195 195
      * @throws ParameterError
196 196
      */
197 197
 
198
-    public function SendPayment($to, $amount, $from=null, $fee=null, $fee_per_byte=null){
199
-        if(!isset($amount))
198
+    public function SendPayment($to, $amount, $from = null, $fee = null, $fee_per_byte = null) {
199
+        if (!isset($amount))
200 200
             throw new ParameterError("Amount required.");
201 201
 
202 202
         $params = array(
203 203
             'to'=>$to,
204 204
             'amount'=>$amount
205 205
         );
206
-        if(!is_null($from))
206
+        if (!is_null($from))
207 207
             $params['from'] = $from;
208
-        if(!is_null($fee))
208
+        if (!is_null($fee))
209 209
             $params['fee'] = $fee;
210
-        if(!is_null($fee_per_byte))
210
+        if (!is_null($fee_per_byte))
211 211
             $params['fee_per_byte'] = $fee_per_byte;
212
-        $response = $this->call('payment',$params);
212
+        $response = $this->call('payment', $params);
213 213
         return new PaymentResponse($response);
214 214
     }
215 215
 
@@ -222,17 +222,17 @@  discard block
 block discarded – undo
222 222
      * @param integer|null $fee_per_byte must be in satoshi
223 223
      */
224 224
 
225
-    public function SendManyPayment($recipients, $from=null, $fee=null, $fee_per_byte = null){
225
+    public function SendManyPayment($recipients, $from = null, $fee = null, $fee_per_byte = null) {
226 226
         $params = array(
227 227
             'recipients'=>json_encode($recipients)
228 228
         );
229
-        if(!is_null($from))
229
+        if (!is_null($from))
230 230
             $params['from'] = $from;
231
-        if(!is_null($fee))
231
+        if (!is_null($fee))
232 232
             $params['fee'] = $fee;
233
-        if(!is_null($fee_per_byte))
233
+        if (!is_null($fee_per_byte))
234 234
             $params['fee_per_byte'] = $fee_per_byte;
235
-        $response = $this->call('sendmany',$params);
235
+        $response = $this->call('sendmany', $params);
236 236
         return new PaymentResponse($response);
237 237
     }
238 238
 
Please login to merge, or discard this patch.
src/Classes/Receive.php 1 patch
Spacing   +21 added lines, -21 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
      * @var Blockchain
18 18
      */
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
      * @param Blockchain $blockchain
30 30
      */
31 31
 
32
-    public function __construct($config){
32
+    public function __construct($config) {
33 33
         $this->client = new Client(['base_uri'=>self::URL]);
34 34
         $this->params = [
35
-            'key'=>data_get('api_code',null)
35
+            'key'=>data_get('api_code', null)
36 36
         ];
37 37
     }
38 38
 
@@ -44,14 +44,14 @@  discard block
 block discarded – undo
44 44
      * @param int $gap_limit How many unused addresses are allowed.
45 45
      * @return ReceiveResponse
46 46
      */
47
-    public function Generate($xpub, $callback, $gap_limit = 20){
47
+    public function Generate($xpub, $callback, $gap_limit = 20) {
48 48
         $params = [
49 49
             'xpub' => $xpub,
50 50
             'callback' => $callback,
51 51
             'gap_limit' => $gap_limit
52 52
         ];
53 53
         $params = array_merge($this->params, $params);
54
-        $response = json_decode($this->client->get('',['query'=>$params]),true);
54
+        $response = json_decode($this->client->get('', ['query'=>$params]), true);
55 55
         return new ReceiveResponse($response);
56 56
     }
57 57
 
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
      * @return integer
63 63
      * @throws \GuzzleHttp\Exception\GuzzleException
64 64
      */
65
-    public function AddressGap($xpub){
66
-        $params = array_merge(['xpub'=>$xpub],$this->params);
67
-        $response = json_decode($this->client->get('checkgap',['query'=>$params]),true);
65
+    public function AddressGap($xpub) {
66
+        $params = array_merge(['xpub'=>$xpub], $this->params);
67
+        $response = json_decode($this->client->get('checkgap', ['query'=>$params]), true);
68 68
         return $response['gap'];
69 69
     }
70 70
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      * @return NotificationResponse
82 82
      */
83 83
 
84
-    public function BalanceNotification($address, $callback, $on = Notification::KEEP, $confs = 3, $op = Operation::ALL){
84
+    public function BalanceNotification($address, $callback, $on = Notification::KEEP, $confs = 3, $op = Operation::ALL) {
85 85
         $params = [
86 86
             'address' => $address,
87 87
             'callback' => $callback,
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
             'op' => $op
91 91
         ];
92 92
         $params = array_merge($this->params, $params);
93
-        $response = json_decode($this->client->post('balance_update',['form_params'=>$params]),true);
93
+        $response = json_decode($this->client->post('balance_update', ['form_params'=>$params]), true);
94 94
         return new NotificationResponse($response);
95 95
     }
96 96
 
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
      * @throws \GuzzleHttp\Exception\GuzzleException
103 103
      */
104 104
 
105
-    public function DeleteBalanceNotification($id){
106
-       $response = json_decode($this->client->delete('balance_update/'.$id, ['query'=>$this->params]),true);
105
+    public function DeleteBalanceNotification($id) {
106
+       $response = json_decode($this->client->delete('balance_update/'.$id, ['query'=>$this->params]), true);
107 107
        return $response['deleted'];
108 108
     }
109 109
 
@@ -118,16 +118,16 @@  discard block
 block discarded – undo
118 118
      * @throws \GuzzleHttp\Exception\GuzzleException
119 119
      */
120 120
 
121
-    public function BlockNotification($callback, $on = Notification::KEEP, $confs = 1, $height = null){
121
+    public function BlockNotification($callback, $on = Notification::KEEP, $confs = 1, $height = null) {
122 122
         $params = [
123 123
             'callback' => $callback,
124 124
             'onNotification' => $on,
125 125
             'confs' => $confs,
126 126
         ];
127
-        if(!is_null($height))
127
+        if (!is_null($height))
128 128
             $params['height'] = $height;
129 129
         $params = array_merge($this->params, $params);
130
-        $response = json_decode($this->client->post('block_notification',['form_params'=>$params]),true);
130
+        $response = json_decode($this->client->post('block_notification', ['form_params'=>$params]), true);
131 131
         return new NotificationResponse($response);
132 132
     }
133 133
 
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
      * @throws \GuzzleHttp\Exception\GuzzleException
140 140
      */
141 141
 
142
-    public function DeleteBlockNotification($id){
143
-        $response = json_decode($this->client->delete('block_notification/'.$id,['query'=>$this->params]),true);
142
+    public function DeleteBlockNotification($id) {
143
+        $response = json_decode($this->client->delete('block_notification/'.$id, ['query'=>$this->params]), true);
144 144
         return $response['deleted'];
145 145
     }
146 146
 
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
      * @throws \GuzzleHttp\Exception\GuzzleException
153 153
      */
154 154
 
155
-    public function CallbackLogs($callback){
156
-        $params = array_merge(['callback'=>$callback],$this->params);
157
-        $logs = json_decode($this->client->get('callback_log',['query'=>$params]),true);
155
+    public function CallbackLogs($callback) {
156
+        $params = array_merge(['callback'=>$callback], $this->params);
157
+        $logs = json_decode($this->client->get('callback_log', ['query'=>$params]), true);
158 158
         $response = array();
159
-        foreach ($logs as $log){
159
+        foreach ($logs as $log) {
160 160
             $response[] = new LogResponse($log);
161 161
         }
162 162
         return $response;
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),true);
70
+            return json_decode($this->client->request($method, $url, $options), true);
71 71
         } catch (GuzzleException $e) {
72 72
             //throw $e->getMessage();
73 73
         }
Please login to merge, or discard this patch.