Merchant   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
c 1
b 0
f 0
dl 0
loc 31
rs 10
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A getMerchantAccessToken() 0 25 5
1
<?php
2
3
namespace bSecure\Payments\Models;
4
5
use bSecure\Payments\Helpers\Helper;
6
use Illuminate\Database\Eloquent\Model;
0 ignored issues
show
Bug introduced by
The type Illuminate\Database\Eloquent\Model was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
class Merchant extends Model
9
{
10
    /**
11
     * Author: Sara Hasan
12
     * Date: 10-November-2020
13
     */
14
    public static function getMerchantAccessToken()
15
    {
16
        $merchantClientId = config('bSecurePayments.client_id');
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

16
        $merchantClientId = /** @scrutinizer ignore-call */ config('bSecurePayments.client_id');
Loading history...
17
        $merchantClientSecret = config('bSecurePayments.client_secret');
18
19
        $merchantAppCredentials = ClientApp::verifyAppCredentials($merchantClientId, $merchantClientSecret);
20
        $merchantAppCredentials['store_id'] = config('bSecurePayments.store_slug');
21
22
        if (empty($merchantAppCredentials)) {
23
            return ['error' => true, 'message' => trans('bSecurePayments::messages.client.invalid')];
0 ignored issues
show
Bug introduced by
The function trans was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
            return ['error' => true, 'message' => /** @scrutinizer ignore-call */ trans('bSecurePayments::messages.client.invalid')];
Loading history...
24
        } else {
25
            if (!empty($merchantAppCredentials['client_id'])) {
26
                // Get Merchant Access Token
27
                $merchantToken = Helper::getAccessToken($merchantAppCredentials);
28
29
                if ($merchantToken['error']) {
30
                    return ['error' => true, 'message' => $merchantToken['message']];
31
                } else {
32
                    return ['error' => false, 'body' => $merchantToken['accessToken']];
33
                }
34
35
            } else if ($merchantAppCredentials['error']) {
36
                return $merchantAppCredentials;
37
            } else {
38
                return ['error' => true, 'message' => trans('bSecurePayments::messages.general.failed')];
39
            }
40
        }
41
    }
42
}
43