Completed
Branch master (7df6ea)
by Emmanuel
04:49
created
src/Payant.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -590,7 +590,7 @@
 block discarded – undo
590 590
 
591 591
     /**
592 592
     * [addPayment]
593
-    * @param [string] $method       [Mandatory - request method <get | post | put | delete> ]
593
+    * @param string $method       [Mandatory - request method <get | post | put | delete> ]
594 594
     * @param [string] $url           [Mandatory - url to send request to]
595 595
     * @param [array] $params         [data to post to request url]
596 596
     */
Please login to merge, or discard this patch.
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
     /**
23 23
      * @var $private_key
24
-    */
24
+     */
25 25
     protected $private_key;
26 26
     
27 27
 
@@ -29,14 +29,14 @@  discard block
 block discarded – undo
29 29
      *
30 30
      * @var $base_uri
31 31
      *
32
-    */
32
+     */
33 33
     protected $base_uri = 'https://api.payant.ng';
34 34
     
35 35
     
36 36
     /**
37 37
      * @var $client
38 38
      *
39
-    */
39
+     */
40 40
     protected $client;
41 41
 
42 42
     
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
     }
52 52
 
53 53
     /**
54
-    * Get Base Url from Payant config file
55
-    */
54
+     * Get Base Url from Payant config file
55
+     */
56 56
     public function setBaseUrl()
57 57
     {
58 58
         if(Config::get('payantng.isdemo') == 'TRUE')
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      */
76 76
     private function setRequestOptions()
77 77
     {       
78
-       $authorization_string = 'Bearer '. $this->private_key;
78
+        $authorization_string = 'Bearer '. $this->private_key;
79 79
 
80 80
         //Set up Guzzle
81 81
         $this->client = new Client( [
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     /**
93 93
      * [getStates Get States in a country (Nigeria)]
94 94
      * @return [object] [list of banks and their respective bank_ids]
95
-    */
95
+     */
96 96
     public function getBanks(){
97 97
         return $this->sendRequest('get', '/banks');
98 98
     }
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
      * [resolveAccount description]
104 104
      * @param array $client_data [description]
105 105
      * Required fields - 'settlement_bank', 'account_number'
106
-    */
106
+     */
107 107
     public function resolveAccount( array $client_data){
108 108
         // Mandatory fields
109 109
         $required_values = ['settlement_bank', 'account_number'];
110 110
 
111 111
         if(!array_keys_exist($client_data, $required_values)){
112
-         throw new Exception\RequiredValuesMissing("Missing required values :(");
112
+            throw new Exception\RequiredValuesMissing("Missing required values :(");
113 113
         }
114 114
 
115 115
         $url = '/resolve-account';
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
      * @param array $client_data [description]
126 126
      * Required fields - 'first_name', 'last_name', 'email', 'phone'
127 127
      * Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number'
128
-    */
128
+     */
129 129
     public function addClient( array $client_data){
130 130
         // Mandatory fields
131 131
         $required_values = ['first_name', 'last_name', 'email', 'phone'];
132 132
 
133 133
         if(!array_keys_exist($client_data, $required_values)){
134
-         throw new Exception\RequiredValuesMissing("Missing required values :(");
134
+            throw new Exception\RequiredValuesMissing("Missing required values :(");
135 135
         }
136 136
 
137 137
         $url = '/clients';
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      * [getClient Get client Details]
147 147
      * @param  [string] $client_id
148 148
      * @return [object]
149
-    */
149
+     */
150 150
     public function getClient($client_id = null){
151 151
         if(!$client_id){
152 152
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id");
@@ -162,15 +162,15 @@  discard block
 block discarded – undo
162 162
 
163 163
 
164 164
     /**
165
-    * [editClient - Edit Existing Client]
166
-    * @param [string] $client_id
167
-    * @param [array] $client_data
168
-    *        Required fields - 'first_name', 'last_name', 'email', 'phone'
169
-    *        Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number'
170
-    */
165
+     * [editClient - Edit Existing Client]
166
+     * @param [string] $client_id
167
+     * @param [array] $client_data
168
+     *        Required fields - 'first_name', 'last_name', 'email', 'phone'
169
+     *        Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number'
170
+     */
171 171
     public function editClient( $client_id, array $client_data){
172 172
         if(!$client_id){
173
-           throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id");
173
+            throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id");
174 174
         }
175 175
 
176 176
         $url = "/clients/{$client_id}";
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
         $required_values = ['first_name', 'last_name', 'email', 'phone'];
180 180
 
181 181
         if(!array_keys_exist($client_data, $required_values)){
182
-             throw new Exception\RequiredValuesMissing("Missing required values :(");
182
+                throw new Exception\RequiredValuesMissing("Missing required values :(");
183 183
         }
184 184
 
185 185
         return $this->sendRequest('put', $url, ['form_params' => $client_data]);
@@ -263,10 +263,10 @@  discard block
 block discarded – undo
263 263
 
264 264
 
265 265
     /**
266
-    * [getInvoice ]
267
-    * @param  [string] $reference_code [Mandatory - Invoice Reference Code]
268
-    * @return [object]               
269
-    */
266
+     * [getInvoice ]
267
+     * @param  [string] $reference_code [Mandatory - Invoice Reference Code]
268
+     * @return [object]               
269
+     */
270 270
     public function getInvoice($reference_code){
271 271
         if(!$reference_code){
272 272
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code");
@@ -278,10 +278,10 @@  discard block
 block discarded – undo
278 278
     }
279 279
 
280 280
     /**
281
-    * [sendInvoice]
282
-    * @param  [type] $reference_code [Mandatory - Invoice Reference Code]
283
-    * @return [object]               
284
-    */
281
+     * [sendInvoice]
282
+     * @param  [type] $reference_code [Mandatory - Invoice Reference Code]
283
+     * @return [object]               
284
+     */
285 285
     public function sendInvoice($reference_code = null){
286 286
         if(!$reference_code){
287 287
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code");
@@ -297,12 +297,12 @@  discard block
 block discarded – undo
297 297
 
298 298
 
299 299
     /**
300
-    * [getInvoiceHistory]
301
-    * @param  [string] $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]]
302
-    * @param  [string] $start  [Format - DD/MM/YYYY]
303
-    * @param  [string] $end    [Format - DD/MM/YYYY]
304
-    * @return [object]         
305
-    */
300
+     * [getInvoiceHistory]
301
+     * @param  [string] $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]]
302
+     * @param  [string] $start  [Format - DD/MM/YYYY]
303
+     * @param  [string] $end    [Format - DD/MM/YYYY]
304
+     * @return [object]         
305
+     */
306 306
     public function getInvoiceHistory($period, $start = null, $end = null){
307 307
         if(!$period){
308 308
             throw new Exception\RequiredValueMissing("Error Processing Request - period Missing");
@@ -337,10 +337,10 @@  discard block
 block discarded – undo
337 337
 
338 338
 
339 339
     /**
340
-    * [deleteInvoice]
341
-    * @param  [string] $reference_code [Mandatory - Invoice Reference Code]
342
-    * @return [object]                 
343
-    */
340
+     * [deleteInvoice]
341
+     * @param  [string] $reference_code [Mandatory - Invoice Reference Code]
342
+     * @return [object]                 
343
+     */
344 344
     public function deleteInvoice($reference_code){
345 345
         if(!$reference_code){
346 346
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code");
@@ -356,12 +356,12 @@  discard block
 block discarded – undo
356 356
 
357 357
 
358 358
     /**
359
-    * [addPayment]
360
-    * @param [string] $reference_code [Mandatory - Invoice Reference Code]
361
-    * @param [string] $date           [Mandatory - [Format - DD/MM/YYYY]]
362
-    * @param [string] $amount         [Mandatory]
363
-    * @param [string] $channel        [Mandatory - valid ["Cash", "BankTransfer", "POS", "Cheque"]]
364
-    */
359
+     * [addPayment]
360
+     * @param [string] $reference_code [Mandatory - Invoice Reference Code]
361
+     * @param [string] $date           [Mandatory - [Format - DD/MM/YYYY]]
362
+     * @param [string] $amount         [Mandatory]
363
+     * @param [string] $channel        [Mandatory - valid ["Cash", "BankTransfer", "POS", "Cheque"]]
364
+     */
365 365
     public function addPayment(string $reference_code, string $date, string $amount, string $channel){
366 366
         if(!$reference_code){
367 367
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code");
@@ -400,9 +400,9 @@  discard block
 block discarded – undo
400 400
 
401 401
 
402 402
     /**
403
-    * [getPayment]
404
-    * @param [string] $reference_code [Mandatory - Invoice Reference Code]
405
-    */
403
+     * [getPayment]
404
+     * @param [string] $reference_code [Mandatory - Invoice Reference Code]
405
+     */
406 406
     public function getPayment($reference_code){
407 407
         if(!$reference_code){
408 408
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code");
@@ -418,12 +418,12 @@  discard block
 block discarded – undo
418 418
 
419 419
 
420 420
     /**
421
-    * [getPaymentHistory]
422
-    * @param  [string] $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]]
423
-    * @param  [string] $start  [Format - DD/MM/YYYY || Optional if $period !== 'custom']
424
-    * @param  [string] $end    [Format - DD/MM/YYYY || Optional if $period !== 'custom']
425
-    * @return [object]         
426
-    */
421
+     * [getPaymentHistory]
422
+     * @param  [string] $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]]
423
+     * @param  [string] $start  [Format - DD/MM/YYYY || Optional if $period !== 'custom']
424
+     * @param  [string] $end    [Format - DD/MM/YYYY || Optional if $period !== 'custom']
425
+     * @return [object]         
426
+     */
427 427
     public function getPaymentHistory(string $period, string $start, string $end){
428 428
         if(!$period){
429 429
             throw new Exception\RequiredValueMissing("Error Processing Request - period Missing");
@@ -458,12 +458,12 @@  discard block
 block discarded – undo
458 458
 
459 459
 
460 460
     /**
461
-    * [addProduct]
462
-    * @param string $name        [Mandatory - Product's name]
463
-    * @param string $description [Mandatory - Product's description]
464
-    * @param string $unit_cost   [Mandatory - Product's unit cost]
465
-    * @param string $type        [Mandatory - Product type 'product' or 'service']
466
-    */
461
+     * [addProduct]
462
+     * @param string $name        [Mandatory - Product's name]
463
+     * @param string $description [Mandatory - Product's description]
464
+     * @param string $unit_cost   [Mandatory - Product's unit cost]
465
+     * @param string $type        [Mandatory - Product type 'product' or 'service']
466
+     */
467 467
     public function addProduct(string $name, string $description, string $unit_cost, string $type){
468 468
         if(!$name){
469 469
             throw new Exception\IsNull("Error Processing Request - Null/Invalid name");
@@ -503,10 +503,10 @@  discard block
 block discarded – undo
503 503
 
504 504
 
505 505
     /**
506
-    * [getProduct]
507
-    * @param  [int] $product_id [Mandatory - Product ID]
508
-    * @return [object] 
509
-    */
506
+     * [getProduct]
507
+     * @param  [int] $product_id [Mandatory - Product ID]
508
+     * @return [object] 
509
+     */
510 510
     public function getProduct($product_id){
511 511
         if(!$product_id){
512 512
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid product_id");
@@ -522,14 +522,14 @@  discard block
 block discarded – undo
522 522
 
523 523
 
524 524
     /**
525
-    * [editProduct]
526
-    * @param  string $product_id   [Mandatory - Product ID]
527
-    * @param  array  $product_data [description]
528
-    * @return object               
529
-    */
525
+     * [editProduct]
526
+     * @param  string $product_id   [Mandatory - Product ID]
527
+     * @param  array  $product_data [description]
528
+     * @return object               
529
+     */
530 530
     public function editProduct($product_id, array $product_data){
531 531
         if(!$product_id){
532
-               throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id");
532
+                throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id");
533 533
         }
534 534
 
535 535
         //Validate Type
@@ -543,13 +543,13 @@  discard block
 block discarded – undo
543 543
             throw new Exception\IsInvalid("Invalid Type - Available options: 'product' or 'service'");
544 544
         }
545 545
 
546
-       $url = "/products/{$product_id}";
546
+        $url = "/products/{$product_id}";
547 547
 
548
-       // Mandatory fields
549
-       $required_values = ['name', 'description', 'unit_cost', 'type'];
548
+        // Mandatory fields
549
+        $required_values = ['name', 'description', 'unit_cost', 'type'];
550 550
 
551 551
         if(!array_keys_exist($client_data, $required_values)){
552
-             throw new Exception\RequiredValuesMissing("Missing required values :(");
552
+                throw new Exception\RequiredValuesMissing("Missing required values :(");
553 553
         }
554 554
 
555 555
         return $this->sendRequest('put', $url, ['form_params' => $post_data]);
@@ -559,9 +559,9 @@  discard block
 block discarded – undo
559 559
 
560 560
 
561 561
     /**
562
-    * [getProducts]
563
-    * @return object
564
-    */
562
+     * [getProducts]
563
+     * @return object
564
+     */
565 565
     public function getProducts(){
566 566
         $url = "/products";
567 567
 
@@ -572,10 +572,10 @@  discard block
 block discarded – undo
572 572
 
573 573
 
574 574
     /**
575
-    * [deleteProduct]
576
-    * @param $product_id [Mandatory - Product ID]
577
-    * @return object           
578
-    */
575
+     * [deleteProduct]
576
+     * @param $product_id [Mandatory - Product ID]
577
+     * @return object           
578
+     */
579 579
     public function deleteProduct($product_id){
580 580
         if(!$product_id){
581 581
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id");
@@ -589,11 +589,11 @@  discard block
 block discarded – undo
589 589
 
590 590
 
591 591
     /**
592
-    * [addPayment]
593
-    * @param [string] $method       [Mandatory - request method <get | post | put | delete> ]
594
-    * @param [string] $url           [Mandatory - url to send request to]
595
-    * @param [array] $params         [data to post to request url]
596
-    */
592
+     * [addPayment]
593
+     * @param [string] $method       [Mandatory - request method <get | post | put | delete> ]
594
+     * @param [string] $url           [Mandatory - url to send request to]
595
+     * @param [array] $params         [data to post to request url]
596
+     */
597 597
     public function sendRequest($method, $url, $params=[])
598 598
     {
599 599
         try{
Please login to merge, or discard this patch.
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     */
56 56
     public function setBaseUrl()
57 57
     {
58
-        if(Config::get('payantng.isdemo') == 'TRUE')
58
+        if (Config::get('payantng.isdemo') == 'TRUE')
59 59
         {
60 60
             $this->base_uri = "https://api.demo.payant.ng";
61 61
         }
@@ -75,10 +75,10 @@  discard block
 block discarded – undo
75 75
      */
76 76
     private function setRequestOptions()
77 77
     {       
78
-       $authorization_string = 'Bearer '. $this->private_key;
78
+       $authorization_string = 'Bearer '.$this->private_key;
79 79
 
80 80
         //Set up Guzzle
81
-        $this->client = new Client( [
81
+        $this->client = new Client([
82 82
             'base_uri' => $this->base_uri,
83 83
             'protocols' => ['https'],
84 84
             'headers' => [
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      * [getStates Get States in a country (Nigeria)]
94 94
      * @return [object] [list of banks and their respective bank_ids]
95 95
     */
96
-    public function getBanks(){
96
+    public function getBanks() {
97 97
         return $this->sendRequest('get', '/banks');
98 98
     }
99 99
     
@@ -104,11 +104,11 @@  discard block
 block discarded – undo
104 104
      * @param array $client_data [description]
105 105
      * Required fields - 'settlement_bank', 'account_number'
106 106
     */
107
-    public function resolveAccount( array $client_data){
107
+    public function resolveAccount(array $client_data) {
108 108
         // Mandatory fields
109 109
         $required_values = ['settlement_bank', 'account_number'];
110 110
 
111
-        if(!array_keys_exist($client_data, $required_values)){
111
+        if (!array_keys_exist($client_data, $required_values)) {
112 112
          throw new Exception\RequiredValuesMissing("Missing required values :(");
113 113
         }
114 114
 
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
      * Required fields - 'first_name', 'last_name', 'email', 'phone'
127 127
      * Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number'
128 128
     */
129
-    public function addClient( array $client_data){
129
+    public function addClient(array $client_data) {
130 130
         // Mandatory fields
131 131
         $required_values = ['first_name', 'last_name', 'email', 'phone'];
132 132
 
133
-        if(!array_keys_exist($client_data, $required_values)){
133
+        if (!array_keys_exist($client_data, $required_values)) {
134 134
          throw new Exception\RequiredValuesMissing("Missing required values :(");
135 135
         }
136 136
 
@@ -147,8 +147,8 @@  discard block
 block discarded – undo
147 147
      * @param  [string] $client_id
148 148
      * @return [object]
149 149
     */
150
-    public function getClient($client_id = null){
151
-        if(!$client_id){
150
+    public function getClient($client_id = null) {
151
+        if (!$client_id) {
152 152
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id");
153 153
         }
154 154
 
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
     *        Required fields - 'first_name', 'last_name', 'email', 'phone'
169 169
     *        Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number'
170 170
     */
171
-    public function editClient( $client_id, array $client_data){
172
-        if(!$client_id){
171
+    public function editClient($client_id, array $client_data) {
172
+        if (!$client_id) {
173 173
            throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id");
174 174
         }
175 175
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
         // Mandatory fields
179 179
         $required_values = ['first_name', 'last_name', 'email', 'phone'];
180 180
 
181
-        if(!array_keys_exist($client_data, $required_values)){
181
+        if (!array_keys_exist($client_data, $required_values)) {
182 182
              throw new Exception\RequiredValuesMissing("Missing required values :(");
183 183
         }
184 184
 
@@ -193,8 +193,8 @@  discard block
 block discarded – undo
193 193
      * [deleteClient]
194 194
      * @param  [string] $client_id [description]
195 195
      */
196
-    public function deleteClient($client_id = null){
197
-        if(!$client_id){
196
+    public function deleteClient($client_id = null) {
197
+        if (!$client_id) {
198 198
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id");
199 199
         }
200 200
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
      * @param [string]      $fee_bearer  [Mandatory]
218 218
      * @param array         $items       [Mandatory]
219 219
      */
220
-    public function addInvoice($client_id, array $client_data, $due_date, $fee_bearer, array $items){
220
+    public function addInvoice($client_id, array $client_data, $due_date, $fee_bearer, array $items) {
221 221
         // Mandatory Client fields
222 222
         $required_client_values = ['first_name', 'last_name', 'email', 'phone'];
223 223
         
@@ -227,21 +227,21 @@  discard block
 block discarded – undo
227 227
 
228 228
         
229 229
         // Either the client Id is supplied or a new client data is provided
230
-        if(!$client_id && !array_keys_exist($client_data, $required_client_values)){
230
+        if (!$client_id && !array_keys_exist($client_data, $required_client_values)) {
231 231
             throw new Exception\RequiredValuesMissing("Missing required values :( - Provide client_id or client_data");
232 232
         }
233 233
 
234
-        if(!$due_date){
234
+        if (!$due_date) {
235 235
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid Due Date");
236 236
         }
237 237
 
238
-        if(!$fee_bearer){
238
+        if (!$fee_bearer) {
239 239
             throw new Exception\IsNull("Error Processing Request - Null Fee Bearer");
240 240
         }elseif (!in_array($fee_bearer, $valid_fee_bearers)) {
241 241
             throw new Exception\InvalidFeeBearer("Invalid Fee Bearer - Use either 'account' or 'client'");
242 242
         }
243 243
 
244
-        if(!is_array($items)){
244
+        if (!is_array($items)) {
245 245
             throw new Exception\IsInvalid("Error Processing Request - Invalid Items");
246 246
         }
247 247
 
@@ -267,8 +267,8 @@  discard block
 block discarded – undo
267 267
     * @param  [string] $reference_code [Mandatory - Invoice Reference Code]
268 268
     * @return [object]               
269 269
     */
270
-    public function getInvoice($reference_code){
271
-        if(!$reference_code){
270
+    public function getInvoice($reference_code) {
271
+        if (!$reference_code) {
272 272
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code");
273 273
         }
274 274
 
@@ -282,8 +282,8 @@  discard block
 block discarded – undo
282 282
     * @param  [type] $reference_code [Mandatory - Invoice Reference Code]
283 283
     * @return [object]               
284 284
     */
285
-    public function sendInvoice($reference_code = null){
286
-        if(!$reference_code){
285
+    public function sendInvoice($reference_code = null) {
286
+        if (!$reference_code) {
287 287
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code");
288 288
         }
289 289
 
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
     * @param  [string] $end    [Format - DD/MM/YYYY]
304 304
     * @return [object]         
305 305
     */
306
-    public function getInvoiceHistory($period, $start = null, $end = null){
307
-        if(!$period){
306
+    public function getInvoiceHistory($period, $start = null, $end = null) {
307
+        if (!$period) {
308 308
             throw new Exception\RequiredValueMissing("Error Processing Request - period Missing");
309 309
         }
310 310
 
@@ -319,8 +319,8 @@  discard block
 block discarded – undo
319 319
             'period' => $period
320 320
         ];
321 321
 
322
-        if ($period == 'custom'){
323
-            if (!$start || !$end){
322
+        if ($period == 'custom') {
323
+            if (!$start || !$end) {
324 324
                 throw new Exception\IsNull("Invalid custom Start or End date");
325 325
             }
326 326
             $post_data['start'] = $start;
@@ -341,8 +341,8 @@  discard block
 block discarded – undo
341 341
     * @param  [string] $reference_code [Mandatory - Invoice Reference Code]
342 342
     * @return [object]                 
343 343
     */
344
-    public function deleteInvoice($reference_code){
345
-        if(!$reference_code){
344
+    public function deleteInvoice($reference_code) {
345
+        if (!$reference_code) {
346 346
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code");
347 347
         }
348 348
 
@@ -362,22 +362,22 @@  discard block
 block discarded – undo
362 362
     * @param [string] $amount         [Mandatory]
363 363
     * @param [string] $channel        [Mandatory - valid ["Cash", "BankTransfer", "POS", "Cheque"]]
364 364
     */
365
-    public function addPayment(string $reference_code, string $date, string $amount, string $channel){
366
-        if(!$reference_code){
365
+    public function addPayment(string $reference_code, string $date, string $amount, string $channel) {
366
+        if (!$reference_code) {
367 367
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code");
368 368
         }
369 369
 
370
-        if(!$due_date){
370
+        if (!$due_date) {
371 371
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid date");
372 372
         }
373 373
 
374
-        if(!$amount){
374
+        if (!$amount) {
375 375
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid amount");
376 376
         }
377 377
 
378 378
         $valid_channels = ["Cash", "BankTransfer", "POS", "Cheque"];
379 379
 
380
-        if(!$channel){
380
+        if (!$channel) {
381 381
             throw new Exception\IsNull("Error Processing Request - Null/Invalid amount");
382 382
         }elseif (!in_array(ucfirst($channel), $valid_channels)) {
383 383
             throw new Exception\IsInvalid("Invalid Channel - Cash, BankTransfer, POS or Cheque");
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
     * [getPayment]
404 404
     * @param [string] $reference_code [Mandatory - Invoice Reference Code]
405 405
     */
406
-    public function getPayment($reference_code){
407
-        if(!$reference_code){
406
+    public function getPayment($reference_code) {
407
+        if (!$reference_code) {
408 408
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code");
409 409
         }
410 410
 
@@ -424,8 +424,8 @@  discard block
 block discarded – undo
424 424
     * @param  [string] $end    [Format - DD/MM/YYYY || Optional if $period !== 'custom']
425 425
     * @return [object]         
426 426
     */
427
-    public function getPaymentHistory(string $period, string $start, string $end){
428
-        if(!$period){
427
+    public function getPaymentHistory(string $period, string $start, string $end) {
428
+        if (!$period) {
429 429
             throw new Exception\RequiredValueMissing("Error Processing Request - period Missing");
430 430
         }
431 431
 
@@ -440,8 +440,8 @@  discard block
 block discarded – undo
440 440
             'period' => $period
441 441
         ];
442 442
 
443
-        if ($period == 'custom'){
444
-            if (!$start || !$end){
443
+        if ($period == 'custom') {
444
+            if (!$start || !$end) {
445 445
                 throw new Exception\IsNull("Invalid custom Start or End date");
446 446
             }
447 447
             $post_data['start'] = $start;
@@ -464,23 +464,23 @@  discard block
 block discarded – undo
464 464
     * @param string $unit_cost   [Mandatory - Product's unit cost]
465 465
     * @param string $type        [Mandatory - Product type 'product' or 'service']
466 466
     */
467
-    public function addProduct(string $name, string $description, string $unit_cost, string $type){
468
-        if(!$name){
467
+    public function addProduct(string $name, string $description, string $unit_cost, string $type) {
468
+        if (!$name) {
469 469
             throw new Exception\IsNull("Error Processing Request - Null/Invalid name");
470 470
         }
471 471
 
472
-        if(!$description){
472
+        if (!$description) {
473 473
             throw new Exception\IsNull("Error Processing Request - Null/Invalid description");
474 474
         }
475 475
 
476
-        if(!$unit_cost){
476
+        if (!$unit_cost) {
477 477
             throw new Exception\IsNull("Error Processing Request - Null/Invalid unit_cost");
478 478
         }
479 479
 
480 480
         //Validate Product Type
481 481
         $valid_product_type = ["product", "service"];
482 482
 
483
-        if(!$type){
483
+        if (!$type) {
484 484
             throw new Exception\IsNull("Error Processing Request - Null/Invalid type");
485 485
         }elseif (!in_array(strtolower($type), $valid_product_type)) {
486 486
             throw new Exception\IsInvalid("Invalid Type - Available options: 'product' or 'service'");
@@ -507,8 +507,8 @@  discard block
 block discarded – undo
507 507
     * @param  [int] $product_id [Mandatory - Product ID]
508 508
     * @return [object] 
509 509
     */
510
-    public function getProduct($product_id){
511
-        if(!$product_id){
510
+    public function getProduct($product_id) {
511
+        if (!$product_id) {
512 512
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid product_id");
513 513
         }
514 514
 
@@ -527,8 +527,8 @@  discard block
 block discarded – undo
527 527
     * @param  array  $product_data [description]
528 528
     * @return object               
529 529
     */
530
-    public function editProduct($product_id, array $product_data){
531
-        if(!$product_id){
530
+    public function editProduct($product_id, array $product_data) {
531
+        if (!$product_id) {
532 532
                throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id");
533 533
         }
534 534
 
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 
538 538
         $valid_product_type = ["product", "service"];
539 539
 
540
-        if(!$product_type){
540
+        if (!$product_type) {
541 541
             throw new Exception\IsNull("Error Processing Request - Null/Invalid type");
542 542
         }elseif (!in_array($product_type, $valid_product_type)) {
543 543
             throw new Exception\IsInvalid("Invalid Type - Available options: 'product' or 'service'");
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
        // Mandatory fields
549 549
        $required_values = ['name', 'description', 'unit_cost', 'type'];
550 550
 
551
-        if(!array_keys_exist($client_data, $required_values)){
551
+        if (!array_keys_exist($client_data, $required_values)) {
552 552
              throw new Exception\RequiredValuesMissing("Missing required values :(");
553 553
         }
554 554
 
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
     * [getProducts]
563 563
     * @return object
564 564
     */
565
-    public function getProducts(){
565
+    public function getProducts() {
566 566
         $url = "/products";
567 567
 
568 568
         return $this->sendRequest('get', $url);
@@ -576,8 +576,8 @@  discard block
 block discarded – undo
576 576
     * @param $product_id [Mandatory - Product ID]
577 577
     * @return object           
578 578
     */
579
-    public function deleteProduct($product_id){
580
-        if(!$product_id){
579
+    public function deleteProduct($product_id) {
580
+        if (!$product_id) {
581 581
             throw new Exception\IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id");
582 582
         }
583 583
 
@@ -594,22 +594,22 @@  discard block
 block discarded – undo
594 594
     * @param [string] $url           [Mandatory - url to send request to]
595 595
     * @param [array] $params         [data to post to request url]
596 596
     */
597
-    public function sendRequest($method, $url, $params=[])
597
+    public function sendRequest($method, $url, $params = [])
598 598
     {
599
-        try{
600
-            if (strtolower($method) == 'get'){
599
+        try {
600
+            if (strtolower($method) == 'get') {
601 601
                 $result = $this->client->request('GET', $url);
602
-            }elseif (strtolower($method) == 'post'){
602
+            }elseif (strtolower($method) == 'post') {
603 603
                 $result = $this->client->request('POST', $url, $params);
604
-            }elseif (strtolower($method) == 'put'){
604
+            }elseif (strtolower($method) == 'put') {
605 605
                 $result = $this->client->request('PUT', $url, $params);
606
-            }elseif (strtolower($method) == 'delete'){
606
+            }elseif (strtolower($method) == 'delete') {
607 607
                 $result = $this->client->request('DELETE', $url);
608 608
             }
609 609
 
610 610
             return cleanResponse($result);
611 611
         }
612
-        catch( Exception $e){
612
+        catch (Exception $e) {
613 613
             throw $e;
614 614
         }
615 615
     }
Please login to merge, or discard this patch.
Braces   +8 added lines, -9 removed lines patch added patch discarded remove patch
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 
238 238
         if(!$fee_bearer){
239 239
             throw new Exception\IsNull("Error Processing Request - Null Fee Bearer");
240
-        }elseif (!in_array($fee_bearer, $valid_fee_bearers)) {
240
+        } elseif (!in_array($fee_bearer, $valid_fee_bearers)) {
241 241
             throw new Exception\InvalidFeeBearer("Invalid Fee Bearer - Use either 'account' or 'client'");
242 242
         }
243 243
 
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 
380 380
         if(!$channel){
381 381
             throw new Exception\IsNull("Error Processing Request - Null/Invalid amount");
382
-        }elseif (!in_array(ucfirst($channel), $valid_channels)) {
382
+        } elseif (!in_array(ucfirst($channel), $valid_channels)) {
383 383
             throw new Exception\IsInvalid("Invalid Channel - Cash, BankTransfer, POS or Cheque");
384 384
         }
385 385
 
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
 
483 483
         if(!$type){
484 484
             throw new Exception\IsNull("Error Processing Request - Null/Invalid type");
485
-        }elseif (!in_array(strtolower($type), $valid_product_type)) {
485
+        } elseif (!in_array(strtolower($type), $valid_product_type)) {
486 486
             throw new Exception\IsInvalid("Invalid Type - Available options: 'product' or 'service'");
487 487
         }
488 488
 
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
 
540 540
         if(!$product_type){
541 541
             throw new Exception\IsNull("Error Processing Request - Null/Invalid type");
542
-        }elseif (!in_array($product_type, $valid_product_type)) {
542
+        } elseif (!in_array($product_type, $valid_product_type)) {
543 543
             throw new Exception\IsInvalid("Invalid Type - Available options: 'product' or 'service'");
544 544
         }
545 545
 
@@ -599,17 +599,16 @@  discard block
 block discarded – undo
599 599
         try{
600 600
             if (strtolower($method) == 'get'){
601 601
                 $result = $this->client->request('GET', $url);
602
-            }elseif (strtolower($method) == 'post'){
602
+            } elseif (strtolower($method) == 'post'){
603 603
                 $result = $this->client->request('POST', $url, $params);
604
-            }elseif (strtolower($method) == 'put'){
604
+            } elseif (strtolower($method) == 'put'){
605 605
                 $result = $this->client->request('PUT', $url, $params);
606
-            }elseif (strtolower($method) == 'delete'){
606
+            } elseif (strtolower($method) == 'delete'){
607 607
                 $result = $this->client->request('DELETE', $url);
608 608
             }
609 609
 
610 610
             return cleanResponse($result);
611
-        }
612
-        catch( Exception $e){
611
+        } catch( Exception $e){
613 612
             throw $e;
614 613
         }
615 614
     }
Please login to merge, or discard this patch.
src/Support/helpers.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,6 @@
 block discarded – undo
2 2
 namespace Olaoluwa98\Payant;
3 3
 
4 4
 use \Exception as phpException;
5
-use Olaoluwa98\Payant\Exception;
6 5
 
7 6
 if (! function_exists('array_get'))
8 7
 {
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 
7 7
 if (! function_exists('array_get'))
8 8
 {
9
-  /*
9
+    /*
10 10
    *
11 11
    * @param array  $data
12 12
    * @param string $key
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
    *
15 15
    * @return mixed
16 16
    */
17
-   function array_get($data, $key, $default = false) {
18
-     if (!is_array($data)) {
19
-         return $default;
20
-     }
21
-     return isset($data[$key]) ? $data[$key]: $default;
22
-   }
17
+    function array_get($data, $key, $default = false) {
18
+        if (!is_array($data)) {
19
+            return $default;
20
+        }
21
+        return isset($data[$key]) ? $data[$key]: $default;
22
+    }
23 23
 }
24 24
 
25 25
 if(!function_exists('array_keys_exist')){
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 }
49 49
 
50 50
 function cleanResponse($response){
51
-	$result = $response->getBody();
52
-	return json_decode($result);
51
+    $result = $response->getBody();
52
+    return json_decode($result);
53 53
 }
54
- ?>
54
+    ?>
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 use \Exception as phpException;
5 5
 use Olaoluwa98\Payant\Exception;
6 6
 
7
-if (! function_exists('array_get'))
7
+if (!function_exists('array_get'))
8 8
 {
9 9
   /*
10 10
    *
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
      if (!is_array($data)) {
19 19
          return $default;
20 20
      }
21
-     return isset($data[$key]) ? $data[$key]: $default;
21
+     return isset($data[$key]) ? $data[$key] : $default;
22 22
    }
23 23
 }
24 24
 
25
-if(!function_exists('array_keys_exist')){
25
+if (!function_exists('array_keys_exist')) {
26 26
     /**
27 27
      * Checks if multiple keys exist in an array
28 28
      *
@@ -31,23 +31,23 @@  discard block
 block discarded – undo
31 31
      *
32 32
      * @return bool
33 33
      */
34
-    function array_keys_exist( array $array, $keys ) {
34
+    function array_keys_exist(array $array, $keys) {
35 35
         $count = 0;
36
-        if ( ! is_array( $keys ) ) {
36
+        if (!is_array($keys)) {
37 37
             $keys = func_get_args();
38
-            array_shift( $keys );
38
+            array_shift($keys);
39 39
         }
40
-        foreach ( $keys as $key ) {
41
-            if ( array_key_exists( $key, $array ) ) {
42
-                $count ++;
40
+        foreach ($keys as $key) {
41
+            if (array_key_exists($key, $array)) {
42
+                $count++;
43 43
             }
44 44
         }
45 45
 
46
-        return count( $keys ) === $count;
46
+        return count($keys) === $count;
47 47
     }
48 48
 }
49 49
 
50
-function cleanResponse($response){
50
+function cleanResponse($response) {
51 51
 	$result = $response->getBody();
52 52
 	return json_decode($result);
53 53
 }
Please login to merge, or discard this patch.
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/Exception.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,4 +10,4 @@
 block discarded – undo
10 10
 class InvalidFeeBearer extends \Exception { }
11 11
 class IsInvalid extends \Exception { }
12 12
 class ApiRequestError extends \Exception { }
13
- ?>
13
+    ?>
Please login to merge, or discard this patch.