GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Order::getOrderStatus()   A
last analyzed

Complexity

Conditions 4
Paths 10

Size

Total Lines 23
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 14
c 1
b 0
f 0
nc 10
nop 1
dl 0
loc 23
rs 9.7998
1
<?php
2
3
namespace bSecure\UniversalCheckout\Models;
4
5
use bSecure\UniversalCheckout\Models\Merchant;
6
use bSecure\UniversalCheckout\Helpers\Helper;
7
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...
8
9
class Order extends Model
10
{
11
    public static $validationRules = [
12
        'createOrder' => [
13
            'order_id'                     => 'required',
14
15
            'shipment_method_name'                     => 'nullable|string',
16
            'shipment_charges'                     => 'nullable|numeric',
17
18
            'customer'                     => 'required',
19
            'customer.name'         => 'nullable|string|max:191',
20
            'customer.country_code' => 'nullable|string|min:2|max:3',
21
            'customer.phone_number' => 'nullable|string|min:10|max:10',
22
            'customer.email'        => 'nullable|email',
23
            'customer.auth_code'    => 'nullable|string',
24
25
            'products'                     => 'required',
26
            'products.*.id'                => 'required|string|min:1|max:100|not_in:0',
27
            'products.*.name'              => 'required|string',
28
            'products.*.sku'               => 'nullable|string|max:50',
29
            'products.*.quantity'          => 'required|integer|max:9999',
30
            'products.*.price'             => 'required|numeric|not_in:0',
31
            'products.*.sale_price'        => 'required|numeric',
32
            'products.*.image'             => 'nullable|url',
33
            'products.*.description'       => 'nullable|string',
34
            'products.*.short_description' => 'nullable|string',
35
36
            'products.*.product_options' => 'nullable',
37
            'products.*.product_options.*.id' => 'nullable|numeric',
38
            'products.*.product_options.*.name' => 'nullable|string',
39
            'products.*.product_options.*.value' => 'nullable',
40
            'products.*.product_options.*.value.name' => 'nullable|string',
41
            'products.*.product_options.*.value.price' => 'nullable|string',
42
        ],
43
    ];
44
45
46
    /**
47
     * Author: Sara Hasan
48
     * Date: 10-November-2020
49
     */
50
    public static function createMerchantOrder($orderPayload)
51
    {
52
        try {
53
            $merchantToken = Merchant::getMerchantAccessToken();
54
55
            if ($merchantToken['error']) {
56
                return ['error' => true, 'message' => $merchantToken['message']];
57
            } else {
58
                $merchantAccessToken = $merchantToken['body'];
59
                // Call Create Order API
60
                $order_response = Helper::createOrder($merchantAccessToken, $orderPayload);
61
62
                if ($order_response['error']) {
63
                    return ['error' => true, 'message' => $order_response['body']['message']];
64
                } else {
65
                    return $order_response;
66
                }
67
            }
68
        } catch (\Exception $e) {
69
            return ['error' => true, 'message' => trans('bSecure::messages.order.failure'), 'exception' => $e->getTraceAsString()];
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

69
            return ['error' => true, 'message' => /** @scrutinizer ignore-call */ trans('bSecure::messages.order.failure'), 'exception' => $e->getTraceAsString()];
Loading history...
70
        }
71
    }
72
73
74
    /**
75
     * Author: Sara Hasan
76
     * Date: 10-November-2020
77
     */
78
    public static function getOrderStatus($order_ref)
79
    {
80
        try {
81
            $merchantToken = Merchant::getMerchantAccessToken();
82
83
            if ($merchantToken['error']) {
84
                return ['error' => true, 'message' => $merchantToken['message']];
85
            } else {
86
                $merchantAccessToken = $merchantToken['body'];
87
                // Call Order Status Update API
88
89
                $payload = ['order_ref' => $order_ref];
90
91
                $order_response = Helper::orderStatus($merchantAccessToken, $payload);
92
93
                if ($order_response['error']) {
94
                    return ['error' => true, 'message' => $order_response['body']['message']];
95
                } else {
96
                    return $order_response;
97
                }
98
            }
99
        } catch (\Exception $e) {
100
            return ['error' => true, 'message' => trans('bSecure::messages.order.status.failure'), 'exception' => $e->getTraceAsString()];
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

100
            return ['error' => true, 'message' => /** @scrutinizer ignore-call */ trans('bSecure::messages.order.status.failure'), 'exception' => $e->getTraceAsString()];
Loading history...
101
        }
102
    }
103
104
105
106
    /**
107
     * Author: Sara Hasan
108
     * Date: 10-November-2020
109
     */
110
    public static function updateManualOrderStatus($payload)
111
    {
112
        try {
113
            $merchantToken = Merchant::getMerchantAccessToken();
114
115
            if ($merchantToken['error']) {
116
                return ['error' => true, 'message' => $merchantToken['message']];
117
            } else {
118
                $merchantAccessToken = $merchantToken['body'];
119
                // Call Order Status Update API
120
                $order_response = Helper::manualOrderStatusUpdate($merchantAccessToken, $payload);
121
122
                if ($order_response['error']) {
123
                    return ['error' => true, 'message' => $order_response['body']['message']];
124
                } else {
125
                    return $order_response;
126
                }
127
            }
128
        } catch (\Exception $e) {
129
            return ['error' => true, 'message' => trans('bSecure::messages.order.status.failure'), 'exception' => $e->getTraceAsString()];
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

129
            return ['error' => true, 'message' => /** @scrutinizer ignore-call */ trans('bSecure::messages.order.status.failure'), 'exception' => $e->getTraceAsString()];
Loading history...
130
        }
131
    }
132
133
134
    /**
135
     * Author: Sara Hasan
136
     * Date: 26-November-2020
137
     */
138
    public static function getMerchantStatus($order_ref)
139
    {
140
        try {
141
            $merchantToken = Merchant::getMerchantAccessToken();
142
143
            if ($merchantToken['error']) {
144
                return ['error' => true, 'message' => $merchantToken['message']];
145
            } else {
146
                $merchantAccessToken = $merchantToken['body'];
147
                // Call Create Order API
148
                $order_response = Helper::createOrder($merchantAccessToken, $order_ref);
149
150
                if ($order_response['error']) {
151
                    return ['error' => true, 'message' => $order_response['body']['message']];
152
                } else {
153
                    return $order_response;
154
                }
155
            }
156
        } catch (\Exception $e) {
157
            return ['error' => true, 'message' => trans('bSecure::messages.order.status.failure'), 'exception' => $e->getTraceAsString()];
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

157
            return ['error' => true, 'message' => /** @scrutinizer ignore-call */ trans('bSecure::messages.order.status.failure'), 'exception' => $e->getTraceAsString()];
Loading history...
158
        }
159
    }
160
}
161