Passed
Push — master ( 5effd2...12657e )
by Emmanuel
02:22
created
src/PayantServiceProvider.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
     protected $defer = false;
25 25
 
26 26
     /**
27
-    * Publishes all the config file this package needs to function
28
-    */
27
+     * Publishes all the config file this package needs to function
28
+     */
29 29
     public function boot()
30 30
     {
31 31
         $config = realpath(__DIR__.'/../resources/config/payant.php');
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
     }
37 37
 
38 38
     /**
39
-    * Register the application services.
40
-    */
39
+     * Register the application services.
40
+     */
41 41
     public function register()
42 42
     {
43 43
         $this->app->bind('laravel-payant', function () {
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
     }
49 49
 
50 50
     /**
51
-    * Get the services provided by the provider
52
-    * @return array
53
-    */
51
+     * Get the services provided by the provider
52
+     * @return array
53
+     */
54 54
     public function provides()
55 55
     {
56 56
         return ['laravel-payant'];
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
     */
41 41
     public function register()
42 42
     {
43
-        $this->app->bind('laravel-payant', function () {
43
+        $this->app->bind('laravel-payant', function() {
44 44
 
45 45
             return new Payant;
46 46
 
Please login to merge, or discard this patch.
src/Support/helpers.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
 if (! function_exists('array_get'))
27 27
 {
28
-  /*
28
+    /*
29 29
    *
30 30
    * @param array  $data
31 31
    * @param string $key
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
    *
34 34
    * @return mixed
35 35
    */
36
-   function array_get($data, $key, $default = false) {
37
-     if (!is_array($data)) {
38
-         return $default;
39
-     }
40
-     return isset($data[$key]) ? $data[$key]: $default;
41
-   }
36
+    function array_get($data, $key, $default = false) {
37
+        if (!is_array($data)) {
38
+            return $default;
39
+        }
40
+        return isset($data[$key]) ? $data[$key]: $default;
41
+    }
42 42
 }
43 43
 
44 44
 if(!function_exists('array_keys_exist')){
@@ -67,6 +67,6 @@  discard block
 block discarded – undo
67 67
 }
68 68
 
69 69
 function cleanResponse($response){
70
-  $result = $response->getBody();
71
-  return $result;
70
+    $result = $response->getBody();
71
+    return $result;
72 72
 }
73 73
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 
24 24
 use \Exception as phpException;
25 25
 
26
-if (! function_exists('array_get'))
26
+if (!function_exists('array_get'))
27 27
 {
28 28
   /*
29 29
    *
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
      if (!is_array($data)) {
38 38
          return $default;
39 39
      }
40
-     return isset($data[$key]) ? $data[$key]: $default;
40
+     return isset($data[$key]) ? $data[$key] : $default;
41 41
    }
42 42
 }
43 43
 
44
-if(!function_exists('array_keys_exist')){
44
+if (!function_exists('array_keys_exist')) {
45 45
     /**
46 46
      * Checks if multiple keys exist in an array
47 47
      *
@@ -50,23 +50,23 @@  discard block
 block discarded – undo
50 50
      *
51 51
      * @return bool
52 52
      */
53
-    function array_keys_exist( array $array, $keys ) {
53
+    function array_keys_exist(array $array, $keys) {
54 54
         $count = 0;
55
-        if ( ! is_array( $keys ) ) {
55
+        if (!is_array($keys)) {
56 56
             $keys = func_get_args();
57
-            array_shift( $keys );
57
+            array_shift($keys);
58 58
         }
59
-        foreach ( $keys as $key ) {
60
-            if ( array_key_exists( $key, $array ) ) {
61
-                $count ++;
59
+        foreach ($keys as $key) {
60
+            if (array_key_exists($key, $array)) {
61
+                $count++;
62 62
             }
63 63
         }
64 64
 
65
-        return count( $keys ) === $count;
65
+        return count($keys) === $count;
66 66
     }
67 67
 }
68 68
 
69
-function cleanResponse($response){
69
+function cleanResponse($response) {
70 70
   $result = $response->getBody();
71 71
   return $result;
72 72
 }
73 73
\ No newline at end of file
Please login to merge, or discard this patch.
src/Payant.php 2 patches
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
      */
84 84
     private function setRequestOptions()
85 85
     {       
86
-        $authorization_string = 'Bearer '. $this->private_key;
86
+        $authorization_string = 'Bearer '.$this->private_key;
87 87
 
88 88
         //Set up Guzzle
89
-        $this->client = new Client( [
89
+        $this->client = new Client([
90 90
             'base_uri' => $this->base_uri,
91 91
             'protocols' => ['https'],
92 92
             'headers' => [
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      * [getStates Get States in a country (Nigeria)]
103 103
      * @return object [list of banks and their respective bank_ids]
104 104
      */
105
-    public function getBanks(){
105
+    public function getBanks() {
106 106
         return $this->sendRequest('get', '/banks');
107 107
     }
108 108
     
@@ -113,11 +113,11 @@  discard block
 block discarded – undo
113 113
      * @param array $client_data [description]
114 114
      * Required fields - 'settlement_bank', 'account_number'
115 115
      */
116
-    public function resolveAccount( array $client_data){
116
+    public function resolveAccount(array $client_data) {
117 117
         // Mandatory fields
118 118
         $required_values = ['settlement_bank', 'account_number'];
119 119
 
120
-        if(!array_keys_exist($client_data, $required_values)){
120
+        if (!array_keys_exist($client_data, $required_values)) {
121 121
             throw new RequiredValuesMissing("Missing required values :(");
122 122
         }
123 123
 
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
      * Required fields - 'first_name', 'last_name', 'email', 'phone'
136 136
      * Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number'
137 137
      */
138
-    public function addClient( array $client_data){
138
+    public function addClient(array $client_data) {
139 139
         // Mandatory fields
140 140
         $required_values = ['first_name', 'last_name', 'email', 'phone'];
141 141
 
142
-        if(!array_keys_exist($client_data, $required_values)){
142
+        if (!array_keys_exist($client_data, $required_values)) {
143 143
             throw new RequiredValuesMissing("Missing required values :(");
144 144
         }
145 145
 
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
      * @param  string $client_id
157 157
      * @return object
158 158
      */
159
-    public function getClient($client_id = null){
160
-        if(!$client_id){
159
+    public function getClient($client_id = null) {
160
+        if (!$client_id) {
161 161
             throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id");
162 162
         }
163 163
 
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
      *        Required fields - 'first_name', 'last_name', 'email', 'phone'
178 178
      *        Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number'
179 179
      */
180
-    public function editClient( $client_id, array $client_data){
181
-        if(!$client_id){
180
+    public function editClient($client_id, array $client_data) {
181
+        if (!$client_id) {
182 182
             throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id");
183 183
         }
184 184
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
         // Mandatory fields
188 188
         $required_values = ['first_name', 'last_name', 'email', 'phone'];
189 189
 
190
-        if(!array_keys_exist($client_data, $required_values)){
190
+        if (!array_keys_exist($client_data, $required_values)) {
191 191
                 throw new RequiredValuesMissing("Missing required values :(");
192 192
         }
193 193
 
@@ -276,8 +276,8 @@  discard block
 block discarded – undo
276 276
      * @param  string $reference_code [Mandatory - Invoice Reference Code]
277 277
      * @return object               
278 278
      */
279
-    public function getInvoice($reference_code){
280
-        if(!$reference_code){
279
+    public function getInvoice($reference_code) {
280
+        if (!$reference_code) {
281 281
             throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code");
282 282
         }
283 283
 
@@ -291,8 +291,8 @@  discard block
 block discarded – undo
291 291
      * @param  string $reference_code [Mandatory - Invoice Reference Code]
292 292
      * @return object               
293 293
      */
294
-    public function sendInvoice($reference_code = null){
295
-        if(!$reference_code){
294
+    public function sendInvoice($reference_code = null) {
295
+        if (!$reference_code) {
296 296
             throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code");
297 297
         }
298 298
 
@@ -312,8 +312,8 @@  discard block
 block discarded – undo
312 312
      * @param  string $end    [Format - DD/MM/YYYY]
313 313
      * @return object         
314 314
      */
315
-    public function getInvoiceHistory($period, $start = null, $end = null){
316
-        if(!$period){
315
+    public function getInvoiceHistory($period, $start = null, $end = null) {
316
+        if (!$period) {
317 317
             throw new RequiredValueMissing("Error Processing Request - period Missing");
318 318
         }
319 319
 
@@ -350,8 +350,8 @@  discard block
 block discarded – undo
350 350
      * @param  string $reference_code [Mandatory - Invoice Reference Code]
351 351
      * @return object                 
352 352
      */
353
-    public function deleteInvoice($reference_code){
354
-        if(!$reference_code){
353
+    public function deleteInvoice($reference_code) {
354
+        if (!$reference_code) {
355 355
             throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code");
356 356
         }
357 357
 
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
      * @param  string $reference_code [Mandatory - Transfer Reference Code]
403 403
      * @return object               
404 404
      */
405
-    public function getTransfer($reference_code){
406
-        if(!$reference_code){
405
+    public function getTransfer($reference_code) {
406
+        if (!$reference_code) {
407 407
             throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code");
408 408
         }
409 409
 
@@ -424,8 +424,8 @@  discard block
 block discarded – undo
424 424
      * @param  string $end    [Format - DD/MM/YYYY]
425 425
      * @return object         
426 426
      */
427
-    public function getTransferHistory($period, $start = null, $end = null){
428
-        if(!$period){
427
+    public function getTransferHistory($period, $start = null, $end = null) {
428
+        if (!$period) {
429 429
             throw new RequiredValueMissing("Error Processing Request - period Missing");
430 430
         }
431 431
 
@@ -462,8 +462,8 @@  discard block
 block discarded – undo
462 462
      * @param  string $reference_code [Mandatory - Invoice Reference Code]
463 463
      * @return object                 
464 464
      */
465
-    public function deleteTransfer($reference_code){
466
-        if(!$reference_code){
465
+    public function deleteTransfer($reference_code) {
466
+        if (!$reference_code) {
467 467
             throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code");
468 468
         }
469 469
 
@@ -484,22 +484,22 @@  discard block
 block discarded – undo
484 484
      * @param string $amount         [Mandatory]
485 485
      * @param string $channel        [Mandatory - valid ["Cash", "BankTransfer", "POS", "Cheque"]]
486 486
      */
487
-    public function addPayment(string $reference_code, string $date, string $amount, string $channel){
488
-        if(!$reference_code){
487
+    public function addPayment(string $reference_code, string $date, string $amount, string $channel) {
488
+        if (!$reference_code) {
489 489
             throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code");
490 490
         }
491 491
 
492
-        if(!$due_date){
492
+        if (!$due_date) {
493 493
             throw new IsNullOrInvalid("Error Processing Request - Null/Invalid date");
494 494
         }
495 495
 
496
-        if(!$amount){
496
+        if (!$amount) {
497 497
             throw new IsNullOrInvalid("Error Processing Request - Null/Invalid amount");
498 498
         }
499 499
 
500 500
         $valid_channels = ["Cash", "BankTransfer", "POS", "Cheque"];
501 501
 
502
-        if(!$channel){
502
+        if (!$channel) {
503 503
             throw new IsNull("Error Processing Request - Null/Invalid amount");
504 504
         }elseif (!in_array(ucfirst($channel), $valid_channels)) {
505 505
             throw new IsInvalid("Invalid Channel - Cash, BankTransfer, POS or Cheque");
@@ -525,8 +525,8 @@  discard block
 block discarded – undo
525 525
      * [getPayment]
526 526
      * @param string $reference_code [Mandatory - Invoice Reference Code]
527 527
      */
528
-    public function getPayment($reference_code){
529
-        if(!$reference_code){
528
+    public function getPayment($reference_code) {
529
+        if (!$reference_code) {
530 530
             throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code");
531 531
         }
532 532
 
@@ -546,8 +546,8 @@  discard block
 block discarded – undo
546 546
      * @param  string $end    [Format - DD/MM/YYYY || Optional if $period !== 'custom']
547 547
      * @return object         
548 548
      */
549
-    public function getPaymentHistory(string $period, string $start, string $end){
550
-        if(!$period){
549
+    public function getPaymentHistory(string $period, string $start, string $end) {
550
+        if (!$period) {
551 551
             throw new RequiredValueMissing("Error Processing Request - period Missing");
552 552
         }
553 553
 
@@ -586,23 +586,23 @@  discard block
 block discarded – undo
586 586
      * @param string $unit_cost   [Mandatory - Product's unit cost]
587 587
      * @param string $type        [Mandatory - Product type 'product' or 'service']
588 588
      */
589
-    public function addProduct(string $name, string $description, string $unit_cost, string $type){
590
-        if(!$name){
589
+    public function addProduct(string $name, string $description, string $unit_cost, string $type) {
590
+        if (!$name) {
591 591
             throw new IsNull("Error Processing Request - Null/Invalid name");
592 592
         }
593 593
 
594
-        if(!$description){
594
+        if (!$description) {
595 595
             throw new IsNull("Error Processing Request - Null/Invalid description");
596 596
         }
597 597
 
598
-        if(!$unit_cost){
598
+        if (!$unit_cost) {
599 599
             throw new IsNull("Error Processing Request - Null/Invalid unit_cost");
600 600
         }
601 601
 
602 602
         //Validate Product Type
603 603
         $valid_product_type = ["product", "service"];
604 604
 
605
-        if(!$type){
605
+        if (!$type) {
606 606
             throw new IsNull("Error Processing Request - Null/Invalid type");
607 607
         }elseif (!in_array(strtolower($type), $valid_product_type)) {
608 608
             throw new IsInvalid("Invalid Type - Available options: 'product' or 'service'");
@@ -629,8 +629,8 @@  discard block
 block discarded – undo
629 629
      * @param  int $product_id [Mandatory - Product ID]
630 630
      * @return object 
631 631
      */
632
-    public function getProduct($product_id){
633
-        if(!$product_id){
632
+    public function getProduct($product_id) {
633
+        if (!$product_id) {
634 634
             throw new IsNullOrInvalid("Error Processing Request - Null/Invalid product_id");
635 635
         }
636 636
 
@@ -649,8 +649,8 @@  discard block
 block discarded – undo
649 649
      * @param  array  $product_data [description]
650 650
      * @return object               
651 651
      */
652
-    public function editProduct($product_id, array $product_data){
653
-        if(!$product_id){
652
+    public function editProduct($product_id, array $product_data) {
653
+        if (!$product_id) {
654 654
                 throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id");
655 655
         }
656 656
 
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
         // Mandatory fields
671 671
         $required_values = ['name', 'description', 'unit_cost', 'type'];
672 672
 
673
-        if(!array_keys_exist($client_data, $required_values)){
673
+        if (!array_keys_exist($client_data, $required_values)) {
674 674
                 throw new RequiredValuesMissing("Missing required values :(");
675 675
         }
676 676
 
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
      * [getProducts]
685 685
      * @return object
686 686
      */
687
-    public function getProducts(){
687
+    public function getProducts() {
688 688
         $url = "/products";
689 689
 
690 690
         return $this->sendRequest('get', $url);
@@ -698,8 +698,8 @@  discard block
 block discarded – undo
698 698
      * @param $product_id [Mandatory - Product ID]
699 699
      * @return object           
700 700
      */
701
-    public function deleteProduct($product_id){
702
-        if(!$product_id){
701
+    public function deleteProduct($product_id) {
702
+        if (!$product_id) {
703 703
             throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id");
704 704
         }
705 705
 
@@ -716,22 +716,22 @@  discard block
 block discarded – undo
716 716
      * @param string $url           [Mandatory - url to send request to]
717 717
      * @param array $params         [data to post to request url]
718 718
      */
719
-    public function sendRequest($method, $url, $params=[])
719
+    public function sendRequest($method, $url, $params = [])
720 720
     {
721
-        try{
722
-            if (strtolower($method) == 'get'){
721
+        try {
722
+            if (strtolower($method) == 'get') {
723 723
                 $result = $this->client->request('GET', $url);
724
-            }elseif (strtolower($method) == 'post'){
724
+            }elseif (strtolower($method) == 'post') {
725 725
                 $result = $this->client->request('POST', $url, $params);
726
-            }elseif (strtolower($method) == 'put'){
726
+            }elseif (strtolower($method) == 'put') {
727 727
                 $result = $this->client->request('PUT', $url, $params);
728
-            }elseif (strtolower($method) == 'delete'){
728
+            }elseif (strtolower($method) == 'delete') {
729 729
                 $result = $this->client->request('DELETE', $url);
730 730
             }
731 731
 
732 732
             return cleanResponse($result);
733 733
         }
734
-        catch( Exception $e){
734
+        catch (Exception $e) {
735 735
             throw $e;
736 736
         }
737 737
     }
Please login to merge, or discard this patch.
Braces   +8 added lines, -9 removed lines patch added patch discarded remove patch
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 
247 247
         if (!$fee_bearer) {
248 248
             throw new IsNull("Error Processing Request - Null Fee Bearer");
249
-        }elseif (!in_array($fee_bearer, $valid_fee_bearers)) {
249
+        } elseif (!in_array($fee_bearer, $valid_fee_bearers)) {
250 250
             throw new InvalidFeeBearer("Invalid Fee Bearer - Use either 'account' or 'client'");
251 251
         }
252 252
 
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 
502 502
         if(!$channel){
503 503
             throw new IsNull("Error Processing Request - Null/Invalid amount");
504
-        }elseif (!in_array(ucfirst($channel), $valid_channels)) {
504
+        } elseif (!in_array(ucfirst($channel), $valid_channels)) {
505 505
             throw new IsInvalid("Invalid Channel - Cash, BankTransfer, POS or Cheque");
506 506
         }
507 507
 
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
 
605 605
         if(!$type){
606 606
             throw new IsNull("Error Processing Request - Null/Invalid type");
607
-        }elseif (!in_array(strtolower($type), $valid_product_type)) {
607
+        } elseif (!in_array(strtolower($type), $valid_product_type)) {
608 608
             throw new IsInvalid("Invalid Type - Available options: 'product' or 'service'");
609 609
         }
610 610
 
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
 
662 662
         if (!$product_type) {
663 663
             throw new IsNull("Error Processing Request - Null/Invalid type");
664
-        }elseif (!in_array($product_type, $valid_product_type)) {
664
+        } elseif (!in_array($product_type, $valid_product_type)) {
665 665
             throw new IsInvalid("Invalid Type - Available options: 'product' or 'service'");
666 666
         }
667 667
 
@@ -721,17 +721,16 @@  discard block
 block discarded – undo
721 721
         try{
722 722
             if (strtolower($method) == 'get'){
723 723
                 $result = $this->client->request('GET', $url);
724
-            }elseif (strtolower($method) == 'post'){
724
+            } elseif (strtolower($method) == 'post'){
725 725
                 $result = $this->client->request('POST', $url, $params);
726
-            }elseif (strtolower($method) == 'put'){
726
+            } elseif (strtolower($method) == 'put'){
727 727
                 $result = $this->client->request('PUT', $url, $params);
728
-            }elseif (strtolower($method) == 'delete'){
728
+            } elseif (strtolower($method) == 'delete'){
729 729
                 $result = $this->client->request('DELETE', $url);
730 730
             }
731 731
 
732 732
             return cleanResponse($result);
733
-        }
734
-        catch( Exception $e){
733
+        } catch( Exception $e){
735 734
             throw $e;
736 735
         }
737 736
     }
Please login to merge, or discard this patch.