Passed
Push — main ( ac53a4...aee26d )
by Pouya
06:40 queued 03:43
created
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.