Passed
Branch main (f255ee)
by Pouya
04:35 queued 02:16
created
src/Enums/Operation.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@
 block discarded – undo
4 4
 namespace Appino\Blockchain\Interfaces;
5 5
 
6 6
 
7
-abstract class Operation{
7
+abstract class Operation {
8 8
 
9 9
     const SPEND = 'SPEND';
10 10
     const RECEIVE = 'RECEIVE';
Please login to merge, or discard this patch.
src/Enums/Notification.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@
 block discarded – undo
4 4
 namespace Appino\Blockchain\Interfaces;
5 5
 
6 6
 
7
-abstract class Notification{
7
+abstract class Notification {
8 8
 
9 9
     const KEEP = 'KEEP';
10 10
     const DELETE = 'DELETE';
Please login to merge, or discard this patch.
config/config.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,5 +5,5 @@
 block discarded – undo
5 5
  */
6 6
 return [
7 7
     'api_code'=>env('blockchain_api_code'),
8
-    'base_url'=>env('blockchain_base_url','http://localhost:3000/')
8
+    'base_url'=>env('blockchain_base_url', 'http://localhost:3000/')
9 9
 ];
Please login to merge, or discard this patch.
src/BlockchainServiceProvider.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
         $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'blockchain');
57 57
 
58 58
         // Register the main class to use with the facade
59
-        $this->app->singleton('blockchain', function () {
59
+        $this->app->singleton('blockchain', function() {
60 60
             $config = app('config')->get('blockchain');
61 61
             return (new Blockchain($config));
62 62
         });
Please login to merge, or discard this patch.
src/Classes/Blockchain.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 use GuzzleHttp\Exception\GuzzleException;
13 13
 use Illuminate\Contracts\Container\Container;
14 14
 
15
-class Blockchain{
15
+class Blockchain {
16 16
 
17 17
     protected $client;
18 18
     protected $params;
@@ -20,29 +20,29 @@  discard block
 block discarded – undo
20 20
     const GET = 'GET';
21 21
     const POST = 'POST';
22 22
 
23
-    public function __construct($config){
24
-        $this->client = new Client(['base_uri'=>data_get($config,'base_uri')]);
25
-        $this->params['api_code'] = data_get($config,'api_code');
23
+    public function __construct($config) {
24
+        $this->client = new Client(['base_uri'=>data_get($config, 'base_uri')]);
25
+        $this->params['api_code'] = data_get($config, 'api_code');
26 26
     }
27 27
 
28 28
     /**
29 29
      * @return Create
30 30
      */
31
-    public function Create(){
31
+    public function Create() {
32 32
         return new Create($this);
33 33
     }
34 34
 
35 35
     /**
36 36
      * @return Wallet
37 37
      */
38
-    public function Wallet(){
38
+    public function Wallet() {
39 39
         return new Wallet($this);
40 40
     }
41 41
 
42 42
     /**
43 43
      * @return Receive
44 44
      */
45
-    public function Receive(){
45
+    public function Receive() {
46 46
         return new Receive($this);
47 47
     }
48 48
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
      * @param $base_uri string Default : http://localhost:3000
51 51
      */
52 52
 
53
-    public function newBaseUri($base_uri){
53
+    public function newBaseUri($base_uri) {
54 54
         $this->client = new Client(['base_uri'=>$base_uri]);
55 55
     }
56 56
 
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
      * @throws HttpError
63 63
      */
64 64
 
65
-    public function Request($method, $url, $params){
65
+    public function Request($method, $url, $params) {
66 66
         $params = array_merge($params, $this->params);
67
-        switch ($method){
67
+        switch ($method) {
68 68
             case 'GET':
69 69
             case 'DELETE':
70 70
                 $options = array('query'=>$params);
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
         }
81 81
         try {
82 82
             $response = $this->client->request($method, $url, $options);
83
-            $json = json_decode($response->getBody()->getContents(),true);
84
-            if(is_null($json)) {
83
+            $json = json_decode($response->getBody()->getContents(), true);
84
+            if (is_null($json)) {
85 85
                 // this is possibly a from btc request with a comma separation
86 86
                 $json = json_decode(str_replace(',', '', $response));
87 87
                 if (is_null($json))
88
-                    throw new Error("Unable to decode JSON response from Blockchain: " . $response->getBody()->getContents());
88
+                    throw new Error("Unable to decode JSON response from Blockchain: ".$response->getBody()->getContents());
89 89
             }
90
-            if(array_key_exists('error', $json)) {
90
+            if (array_key_exists('error', $json)) {
91 91
                 throw new ApiError($json['error']);
92 92
             }
93 93
             return $json;
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
         $response = $this->doCreate($password, null, $email, $label);
28 28
         return new WalletResponse($response);
29 29
     }
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
      * @return WalletResponse
39 39
      * @throws ParameterError
40 40
      */
41
-    public function createWithKey($password, $privKey, $email=null, $label=null) {
42
-        if(!isset($privKey) || is_null($privKey))
41
+    public function createWithKey($password, $privKey, $email = null, $label = null) {
42
+        if (!isset($privKey) || is_null($privKey))
43 43
             throw new ParameterError("Private Key required.");
44 44
 
45 45
         return new WalletResponse($this->doCreate($password, $privKey, $email, $label));
@@ -55,22 +55,22 @@  discard block
 block discarded – undo
55 55
      * @return array
56 56
      * @throws ParameterError
57 57
      */
58
-    protected function doCreate($password, $priv = null, $label = null, $email = null){
59
-        if(!isset($password) || empty($password))
58
+    protected function doCreate($password, $priv = null, $label = null, $email = null) {
59
+        if (!isset($password) || empty($password))
60 60
             throw new ParameterError("Password required.");
61 61
 
62 62
         $params = array(
63 63
             'password'=>$password,
64 64
             'hd'=>true
65 65
         );
66
-        if(!is_null($priv))
66
+        if (!is_null($priv))
67 67
             $params['priv'] = $priv;
68
-        if(!is_null($email))
68
+        if (!is_null($email))
69 69
             $params['email'] = $email;
70
-        if(!is_null($label))
70
+        if (!is_null($label))
71 71
             $params['label'] = $label;
72 72
 
73
-        return $this->blockchain->Request(Blockchain::POST,self::URL,$params);
73
+        return $this->blockchain->Request(Blockchain::POST, self::URL, $params);
74 74
     }
75 75
 
76 76
 }
Please login to merge, or discard this patch.
src/Objects/BalanceCallback.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 
7 7
 use Psy\Util\Json;
8 8
 
9
-class BalanceCallback{
9
+class BalanceCallback {
10 10
 
11 11
     public $transaction_hash;
12 12
     public $address;
@@ -18,21 +18,21 @@  discard block
 block discarded – undo
18 18
      * @param $params
19 19
      */
20 20
 
21
-    public function __construct($params){
22
-        if(is_null($params))
21
+    public function __construct($params) {
22
+        if (is_null($params))
23 23
             return;
24
-        foreach ($params as $key => $value){
24
+        foreach ($params as $key => $value) {
25 25
             $this->{$key} = $value;
26 26
         }
27 27
     }
28 28
 
29
-    public function __toString(){
29
+    public function __toString() {
30 30
         $class_vars = get_class_vars(get_class($this));
31 31
         $response = [];
32
-        foreach ($class_vars as $key => $value){
32
+        foreach ($class_vars as $key => $value) {
33 33
             $response[$key] = $this->{$key};
34 34
         }
35
-        return json_encode($response, JSON_THROW_ON_ERROR) ."";
35
+        return json_encode($response, JSON_THROW_ON_ERROR)."";
36 36
     }
37 37
 
38 38
 }
Please login to merge, or discard this patch.
src/Objects/WalletResponse.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 use Psy\Util\Json;
6 6
 use function Sodium\add;
7 7
 
8
-class WalletResponse{
8
+class WalletResponse {
9 9
 
10 10
     /**
11 11
      * @var string
@@ -25,21 +25,21 @@  discard block
 block discarded – undo
25 25
      * @param $params array|object
26 26
      */
27 27
 
28
-    public function __construct($params){
29
-        if(is_null($params))
28
+    public function __construct($params) {
29
+        if (is_null($params))
30 30
             return;
31
-        $this->guid = data_get($params,'guid');
32
-        $this->address = data_get($params,'address');
33
-        $this->label = data_get($params,'label');
31
+        $this->guid = data_get($params, 'guid');
32
+        $this->address = data_get($params, 'address');
33
+        $this->label = data_get($params, 'label');
34 34
     }
35 35
 
36
-    public function __toString(){
36
+    public function __toString() {
37 37
         $class_vars = get_class_vars(get_class($this));
38 38
         $response = [];
39
-        foreach ($class_vars as $key => $value){
39
+        foreach ($class_vars as $key => $value) {
40 40
             $response[$key] = $this->{$key};
41 41
         }
42
-        return json_encode($response, JSON_THROW_ON_ERROR) ."";
42
+        return json_encode($response, JSON_THROW_ON_ERROR)."";
43 43
     }
44 44
 
45 45
 }
Please login to merge, or discard this patch.
src/Objects/AccountResponse.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 use Appino\Blockchain\Objects\Cache;
6 6
 use Psy\Util\Json;
7 7
 
8
-class AccountResponse{
8
+class AccountResponse {
9 9
     /**
10 10
      * @var string
11 11
      */
@@ -48,28 +48,28 @@  discard block
 block discarded – undo
48 48
      * @param $params array|object
49 49
      */
50 50
 
51
-    public function __construct($params){
51
+    public function __construct($params) {
52 52
         //echo Json::encode($params);
53
-        if(is_null($params))
53
+        if (is_null($params))
54 54
             return;
55
-        $this->balance = data_get($params,'balance');
56
-        $this->label = data_get($params,'label');
57
-        $this->index = data_get($params,'index');
58
-        $this->archived = data_get($params,'archived');
59
-        $this->extendedPublicKey = data_get($params,'extendedPublicKey');
60
-        $this->extendedPrivateKey = data_get($params,'extendedPrivateKey');
61
-        $this->receiveIndex = data_get($params,'receiveIndex');
62
-        $this->lastUsedReceiveIndex = data_get($params,'lastUsedReceiveIndex');
63
-        $this->receiveAddress = data_get($params,'receiveAddress');
55
+        $this->balance = data_get($params, 'balance');
56
+        $this->label = data_get($params, 'label');
57
+        $this->index = data_get($params, 'index');
58
+        $this->archived = data_get($params, 'archived');
59
+        $this->extendedPublicKey = data_get($params, 'extendedPublicKey');
60
+        $this->extendedPrivateKey = data_get($params, 'extendedPrivateKey');
61
+        $this->receiveIndex = data_get($params, 'receiveIndex');
62
+        $this->lastUsedReceiveIndex = data_get($params, 'lastUsedReceiveIndex');
63
+        $this->receiveAddress = data_get($params, 'receiveAddress');
64 64
     }
65 65
 
66
-    public function __toString(){
66
+    public function __toString() {
67 67
         $class_vars = get_class_vars(get_class($this));
68 68
         $response = [];
69
-        foreach ($class_vars as $key => $value){
69
+        foreach ($class_vars as $key => $value) {
70 70
             $response[$key] = $this->{$key};
71 71
         }
72
-        return json_encode($response, JSON_THROW_ON_ERROR) ."";
72
+        return json_encode($response, JSON_THROW_ON_ERROR)."";
73 73
     }
74 74
 
75 75
 }
Please login to merge, or discard this patch.