Passed
Push — main ( 2ca57c...acfaba )
by Pouya
03:36
created
src/Objects/Rate.php 2 patches
Spacing   +8 added lines, -8 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 Rate{
7
+class Rate {
8 8
 
9 9
     public $currency;
10 10
     public $m15;
@@ -12,15 +12,15 @@  discard block
 block discarded – undo
12 12
     public $buy;
13 13
     public $sell;
14 14
 
15
-    public function __construct($currency, $params){
16
-        if(is_null($params))
15
+    public function __construct($currency, $params) {
16
+        if (is_null($params))
17 17
             return;
18 18
         $this->currency = $currency;
19
-        $this->m15 = data_get($params,'15m');
20
-        $this->last = data_get($params,'last');
21
-        $this->buy = data_get($params,'buy');
22
-        $this->sell = data_get($params,'sell');
23
-        $this->symbol = data_get($params,'symbol');
19
+        $this->m15 = data_get($params, '15m');
20
+        $this->last = data_get($params, 'last');
21
+        $this->buy = data_get($params, 'buy');
22
+        $this->sell = data_get($params, 'sell');
23
+        $this->symbol = data_get($params, 'symbol');
24 24
     }
25 25
 
26 26
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@
 block discarded – undo
13 13
     public $sell;
14 14
 
15 15
     public function __construct($currency, $params){
16
-        if(is_null($params))
17
-            return;
16
+        if(is_null($params)) {
17
+                    return;
18
+        }
18 19
         $this->currency = $currency;
19 20
         $this->m15 = data_get($params,'15m');
20 21
         $this->last = data_get($params,'last');
Please login to merge, or discard this patch.
src/Classes/Market.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -7,17 +7,17 @@  discard block
 block discarded – undo
7 7
 use Appino\Blockchain\Objects\Rate;
8 8
 use Appino\Blockchain\Objects\ReceiveResponse;
9 9
 
10
-class Market{
10
+class Market {
11 11
 
12 12
     private $blockchain;
13 13
 
14
-    public function __construct(Blockchain $blockchain){
14
+    public function __construct(Blockchain $blockchain) {
15 15
         $this->blockchain = $blockchain;
16 16
     }
17 17
 
18 18
     const URL = 'https://blockchain.info/';
19 19
 
20
-    private function Uri($uri){
20
+    private function Uri($uri) {
21 21
         return self::URL.'/'.$uri;
22 22
     }
23 23
 
@@ -28,34 +28,34 @@  discard block
 block discarded – undo
28 28
      * @return array|string
29 29
      * @throws \Appino\Blockchain\Exception\HttpError
30 30
      */
31
-    private function call($method, $uri, $params = array()){
31
+    private function call($method, $uri, $params = array()) {
32 32
         return $this->blockchain->Request($method, $this->Uri($uri), $params);
33 33
     }
34 34
 
35
-    public function Rates(){
36
-        $response = $this->call('GET','ticker');
35
+    public function Rates() {
36
+        $response = $this->call('GET', 'ticker');
37 37
         $rates = array();
38
-        foreach ($response as $Currency => $params){
38
+        foreach ($response as $Currency => $params) {
39 39
             $rates[$Currency] = new Rate($Currency, $params);
40 40
         }
41 41
         return $rates;
42 42
     }
43 43
 
44
-    public function ToBTC($currency, $amount){
44
+    public function ToBTC($currency, $amount) {
45 45
         $params = [
46 46
             'currency' => $currency,
47 47
             'value' => $amount
48 48
         ];
49
-        $response = $this->call('GET','tobtc',$params);
49
+        $response = $this->call('GET', 'tobtc', $params);
50 50
         return new ReceiveResponse($response);
51 51
     }
52 52
 
53
-    public function ToSatoshi($currency, $amount){
53
+    public function ToSatoshi($currency, $amount) {
54 54
         $params = [
55 55
             'currency' => $currency,
56 56
             'value' => $amount
57 57
         ];
58
-        return bcmul($this->call('GET','tobtc',$params),100000000);
58
+        return bcmul($this->call('GET', 'tobtc', $params), 100000000);
59 59
     }
60 60
 
61 61
 }
Please login to merge, or discard this patch.
src/Classes/Blockchain.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 use GuzzleHttp\Exception\GuzzleException;
14 14
 use Illuminate\Contracts\Container\Container;
15 15
 
16
-class Blockchain{
16
+class Blockchain {
17 17
 
18 18
     protected $client;
19 19
     protected $params;
@@ -21,37 +21,37 @@  discard block
 block discarded – undo
21 21
     const GET = 'GET';
22 22
     const POST = 'POST';
23 23
 
24
-    public function __construct($config){
25
-        $this->client = new Client(['base_uri'=>data_get($config,'base_uri')]);
26
-        $this->params['api_code'] = data_get($config,'api_code');
27
-        $this->params['key'] = data_get($config,'api_code');
24
+    public function __construct($config) {
25
+        $this->client = new Client(['base_uri'=>data_get($config, 'base_uri')]);
26
+        $this->params['api_code'] = data_get($config, 'api_code');
27
+        $this->params['key'] = data_get($config, 'api_code');
28 28
     }
29 29
 
30 30
     /**
31 31
      * @return Create
32 32
      */
33
-    public function Create(){
33
+    public function Create() {
34 34
         return new Create($this);
35 35
     }
36 36
 
37 37
     /**
38 38
      * @return Wallet
39 39
      */
40
-    public function Wallet(){
40
+    public function Wallet() {
41 41
         return new Wallet($this);
42 42
     }
43 43
 
44 44
     /**
45 45
      * @return Receive
46 46
      */
47
-    public function Receive(){
47
+    public function Receive() {
48 48
         return new Receive($this);
49 49
     }
50 50
 
51 51
     /**
52 52
      * @return Market
53 53
      */
54
-    public function Market(){
54
+    public function Market() {
55 55
         return new Market($this);
56 56
     }
57 57
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      * @param $base_uri string Default : http://localhost:3000
60 60
      */
61 61
 
62
-    public function newBaseUri($base_uri){
62
+    public function newBaseUri($base_uri) {
63 63
         $this->client = new Client(['base_uri'=>$base_uri]);
64 64
     }
65 65
 
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
      * @throws HttpError
72 72
      */
73 73
 
74
-    public function Request($method, $url, $params){
74
+    public function Request($method, $url, $params) {
75 75
         $params = array_merge($params, $this->params);
76
-        switch ($method){
76
+        switch ($method) {
77 77
             case 'GET':
78 78
             case 'DELETE':
79 79
                 $options = array('query'=>$params);
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
         }
92 92
         try {
93 93
             $response = $this->client->request($method, $url, $options);
94
-            $json = json_decode($response->getBody()->getContents(),true);
95
-            if(is_null($json)) {
94
+            $json = json_decode($response->getBody()->getContents(), true);
95
+            if (is_null($json)) {
96 96
                 // this is possibly a from btc request with a comma separation
97 97
                 $json = json_decode(str_replace(',', '', $response));
98 98
                 if (is_null($json))
99
-                    throw new Error("Unable to decode JSON response from Blockchain: " . $response->getBody()->getContents());
99
+                    throw new Error("Unable to decode JSON response from Blockchain: ".$response->getBody()->getContents());
100 100
             }
101
-            if(array_key_exists('error', $json)) {
101
+            if (array_key_exists('error', $json)) {
102 102
                 throw new ApiError($json['error']);
103 103
             }
104 104
             return $json;
Please login to merge, or discard this patch.
src/Classes/Exchange.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -7,17 +7,17 @@  discard block
 block discarded – undo
7 7
 use Appino\Blockchain\Objects\Rate;
8 8
 use Appino\Blockchain\Objects\ReceiveResponse;
9 9
 
10
-class Exchange{
10
+class Exchange {
11 11
 
12 12
     private $blockchain;
13 13
 
14
-    public function __construct(Blockchain $blockchain){
14
+    public function __construct(Blockchain $blockchain) {
15 15
         $this->blockchain = $blockchain;
16 16
     }
17 17
 
18 18
     const URL = 'https://blockchain.info/';
19 19
 
20
-    private function Uri($uri){
20
+    private function Uri($uri) {
21 21
         return self::URL.'/'.$uri;
22 22
     }
23 23
 
@@ -28,26 +28,26 @@  discard block
 block discarded – undo
28 28
      * @return array
29 29
      * @throws \Appino\Blockchain\Exception\HttpError
30 30
      */
31
-    private function call($method, $uri, $params = array()){
31
+    private function call($method, $uri, $params = array()) {
32 32
         return $this->blockchain->Request($method, $this->Uri($uri), $params);
33 33
     }
34 34
 
35
-    public function Rates(){
36
-        $response = $this->call('GET','ticker');
35
+    public function Rates() {
36
+        $response = $this->call('GET', 'ticker');
37 37
         $rates = array();
38
-        foreach ($response as $Currency => $params){
38
+        foreach ($response as $Currency => $params) {
39 39
             $rates[$Currency] = new Rate($Currency, $params);
40 40
         }
41 41
         return $rates;
42 42
     }
43 43
 
44
-    public function ToBTC($currency, $amount){
44
+    public function ToBTC($currency, $amount) {
45 45
         $params = [
46 46
             'currency' => $currency,
47 47
             'value' => $amount
48 48
         ];
49 49
         $params = array_merge($this->params, $params);
50
-        $response = $this->call('GET','',$params);
50
+        $response = $this->call('GET', '', $params);
51 51
         return new ReceiveResponse($response);
52 52
     }
53 53
 
Please login to merge, or discard this patch.
src/Classes/Receive.php 1 patch
Spacing   +22 added lines, -22 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
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
      * @param Blockchain $blockchain
33 33
      */
34 34
 
35
-    public function __construct(Blockchain $blockchain){
35
+    public function __construct(Blockchain $blockchain) {
36 36
         $this->blockchain = $blockchain;
37 37
     }
38 38
 
39
-    private function Uri($uri){
39
+    private function Uri($uri) {
40 40
         return self::URL.'/'.$uri;
41 41
     }
42 42
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      * @return array
48 48
      * @throws \Appino\Blockchain\Exception\HttpError
49 49
      */
50
-    private function call($method, $uri, $params = array()){
50
+    private function call($method, $uri, $params = array()) {
51 51
         return $this->blockchain->Request($method, $this->Uri($uri), $params);
52 52
     }
53 53
 
@@ -59,14 +59,14 @@  discard block
 block discarded – undo
59 59
      * @param int $gap_limit How many unused addresses are allowed.
60 60
      * @return ReceiveResponse
61 61
      */
62
-    public function Generate($xpub, $callback, $gap_limit = 20){
62
+    public function Generate($xpub, $callback, $gap_limit = 20) {
63 63
         $params = [
64 64
             'xpub' => $xpub,
65 65
             'callback' => $callback,
66 66
             'gap_limit' => $gap_limit
67 67
         ];
68 68
         $params = array_merge($this->params, $params);
69
-        $response = $this->call('GET','',$params);
69
+        $response = $this->call('GET', '', $params);
70 70
         return new ReceiveResponse($response);
71 71
     }
72 72
 
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
      * @return integer
78 78
      * @throws \GuzzleHttp\Exception\GuzzleException
79 79
      */
80
-    public function AddressGap($xpub){
81
-        $params = array_merge(['xpub'=>$xpub],$this->params);
82
-        $response = $this->call('GET','checkgap',$params);
80
+    public function AddressGap($xpub) {
81
+        $params = array_merge(['xpub'=>$xpub], $this->params);
82
+        $response = $this->call('GET', 'checkgap', $params);
83 83
         return $response['gap'];
84 84
     }
85 85
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      * @return NotificationResponse
97 97
      */
98 98
 
99
-    public function BalanceNotification($address, $callback, $on = Notification::KEEP, $confs = 3, $op = Operation::ALL){
99
+    public function BalanceNotification($address, $callback, $on = Notification::KEEP, $confs = 3, $op = Operation::ALL) {
100 100
         $params = [
101 101
             'address' => $address,
102 102
             'callback' => $callback,
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
             'op' => $op
106 106
         ];
107 107
         $params = array_merge($this->params, $params);
108
-        $response = $this->call('POST','balance_update',$params);
108
+        $response = $this->call('POST', 'balance_update', $params);
109 109
         return new NotificationResponse($response);
110 110
     }
111 111
 
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
      * @throws \GuzzleHttp\Exception\GuzzleException
118 118
      */
119 119
 
120
-    public function DeleteBalanceNotification($id){
121
-       $response = $this->call('DELETE','balance_update/'.$id, $this->params);
120
+    public function DeleteBalanceNotification($id) {
121
+       $response = $this->call('DELETE', 'balance_update/'.$id, $this->params);
122 122
        return $response['deleted'];
123 123
     }
124 124
 
@@ -133,16 +133,16 @@  discard block
 block discarded – undo
133 133
      * @throws \GuzzleHttp\Exception\GuzzleException
134 134
      */
135 135
 
136
-    public function BlockNotification($callback, $on = Notification::KEEP, $confs = 1, $height = null){
136
+    public function BlockNotification($callback, $on = Notification::KEEP, $confs = 1, $height = null) {
137 137
         $params = [
138 138
             'callback' => $callback,
139 139
             'onNotification' => $on,
140 140
             'confs' => $confs,
141 141
         ];
142
-        if(!is_null($height))
142
+        if (!is_null($height))
143 143
             $params['height'] = $height;
144 144
         $params = array_merge($this->params, $params);
145
-        $response = $this->call('POST','block_notification',$params);
145
+        $response = $this->call('POST', 'block_notification', $params);
146 146
         return new NotificationResponse($response);
147 147
     }
148 148
 
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
      * @throws \GuzzleHttp\Exception\GuzzleException
155 155
      */
156 156
 
157
-    public function DeleteBlockNotification($id){
158
-        $response = $this->call('DELETE','block_notification/'.$id,$this->params);
157
+    public function DeleteBlockNotification($id) {
158
+        $response = $this->call('DELETE', 'block_notification/'.$id, $this->params);
159 159
         return $response['deleted'];
160 160
     }
161 161
 
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
      * @throws \GuzzleHttp\Exception\GuzzleException
168 168
      */
169 169
 
170
-    public function CallbackLogs($callback){
171
-        $params = array_merge(['callback'=>$callback],$this->params);
172
-        $logs = $this->call('GET','callback_log',['query'=>$params]);
170
+    public function CallbackLogs($callback) {
171
+        $params = array_merge(['callback'=>$callback], $this->params);
172
+        $logs = $this->call('GET', 'callback_log', ['query'=>$params]);
173 173
         $response = array();
174
-        foreach ($logs as $log){
174
+        foreach ($logs as $log) {
175 175
             $response[] = new LogResponse($log);
176 176
         }
177 177
         return $response;
Please login to merge, or discard this patch.