Http   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 26
c 1
b 0
f 0
dl 0
loc 49
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getIpDetails() 0 9 1
A getApiPossibleCodes() 0 3 1
1
<?php
2
3
namespace bSecure\Payments\Helpers;
4
5
class Http
6
{
7
    static $RequestHeaders = [
8
        'locale' => 'x-locale',
9
        'currency' => 'x-currency',
10
        'deviceType' => 'x-device-type',
11
        'osVersion' => 'x-os-version',
12
        'appVersion' => 'x-app-version',
13
        'accessToken' => 'x-access-token'
14
    ];
15
16
    static $CurlContentTypes = [
17
        'JSON' => 'Application/json',
18
        'MultiPartFormData' => 'Multipart/form-data'
19
    ];
20
21
    //in case of successful create, read, update, delete & any successful operation
22
    const SUCCESS = "success";
23
24
    //in case of operational or process failure
25
    const BAD_REQUEST = "bad_request";
26
27
    //in case of authentication failure, trying to access any protected route with expired or no API token
28
    const UNAUTHORISED = "unauthorised";
29
30
    //in case of validation failure
31
    const INPROCESSABLE = "inprocessable";
32
33
    static $Codes = [
34
        self::SUCCESS => 200,
35
        self::BAD_REQUEST => 400,
36
        self::UNAUTHORISED => 401,
37
        self::INPROCESSABLE => 422
38
    ];
39
40
    public static function getApiPossibleCodes()
41
    {
42
        return array_values(self::$Codes);
43
    }
44
45
    public static function getIpDetails($ip)
0 ignored issues
show
Unused Code introduced by
The parameter $ip is not used and could be removed. ( Ignorable by Annotation )

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

45
    public static function getIpDetails(/** @scrutinizer ignore-unused */ $ip)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
46
    {
47
        return [
48
            'country_name' => 'Pakistan'
49
        ];
50
51
        $accessKey = env('IPSTACK_API_KEY');
0 ignored issues
show
Bug introduced by
The function env 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

51
        $accessKey = /** @scrutinizer ignore-call */ env('IPSTACK_API_KEY');
Loading history...
Unused Code introduced by
$accessKey = env('IPSTACK_API_KEY') is not reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
52
        $url = env('IPSTACK_URL') . $ip . '?access_key=' . $accessKey;
53
        return Helper::apiRequest('GET', $url);
54
    }
55
}
56