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.

Request::paramsCheckTransaction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Good One Sales
5
 * Date: 9/3/2018
6
 * Time: 5:01 PM
7
 */
8
9
namespace Goodoneuz\PayUz\Http\Classes\Paynet;
10
11
class Request
12
{
13
14
    public $method;
15
16
    const ARGUMENTS_PerformTransaction  = 'PerformTransactionArguments';
17
    const ARGUMENTS_CheckTransaction    = 'CheckTransactionArguments';
18
    const ARGUMENTS_GetStatement        = 'GetStatementArguments';
19
    const ARGUMENTS_CancelTransaction   = 'CancelTransactionArguments';
20
    const ARGUMENTS_GetInformation      = 'GetInformationArguments';
21
22
    const METHOD_PerformTransaction     = 'PerformTransaction';
23
    const METHOD_CheckTransaction       = 'CheckTransaction';
24
    const METHOD_GetStatement           = 'GetStatement';
25
    const METHOD_CancelTransaction      = 'CancelTransaction';
26
    const METHOD_GetInformation         = 'GetInformation';
27
28
    public $params;
29
    private $response;
30
31
    public function __construct($response)
32
    {
33
        $this->response = $response;
34
        $this->params = [];
35
        $arr_params = $this->getRequestArray();
36
        $this->loadAccount($arr_params);
37
38
        foreach ($arr_params as $key => $value){
39
            switch ($key){
40
                case self::ARGUMENTS_PerformTransaction:
41
                    $this->paramsPerformTransaction($arr_params[self::ARGUMENTS_PerformTransaction]);
42
                    break;
43
                case self::ARGUMENTS_CheckTransaction:
44
                    $this->paramsCheckTransaction($arr_params[self::ARGUMENTS_CheckTransaction]);
45
                    break;
46
                case self::ARGUMENTS_GetStatement:
47
                    $this->paramsStament($arr_params[self::ARGUMENTS_GetStatement]);
48
                    break;
49
                case self::ARGUMENTS_CancelTransaction:
50
                    $this->paramsCancel($arr_params[self::ARGUMENTS_CancelTransaction]);
51
                    break;
52
                case self::ARGUMENTS_GetInformation:
53
                    $this->paramsInformation($arr_params[self::ARGUMENTS_GetInformation]);
54
                    break;
55
                default:
56
                    $this->response->response($this,'Error in request', Response::ERROR_METHOD_NOT_FOUND);
57
            }
58
        }
59
    }
60
    public function loadAccount($arr_params){
61
       $arr_params = array_values($arr_params)[0];
62
63
        $this->params['account'] = [
64
            'login' => $arr_params['username'],
65
            'password' => $arr_params['password']
66
        ];
67
        $this->params['serviceId'] = $arr_params['serviceId'];
68
    }
69
    public function getRequestArray(){
70
        $request_body  = file_get_contents('php://input');
71
        $clean_xml = str_ireplace(['soapenv:', 'soap:','xmlns:','xsi:','ns1:'], '', $request_body);
72
        $xml = simplexml_load_string($clean_xml);
73
        $body = null;
74
        if ($xml)
75
            $body = $xml->Body;
0 ignored issues
show
Bug introduced by
The property Body does not seem to exist in SimpleXMLElement.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
76
        else
77
            $this->response->response($this,'Error in request', Response::ERROR_INVALID_JSON_RPC_OBJECT);
78
79
        return json_decode(json_encode($body),1);
80
    }
81
    public function paramsPerformTransaction($par){
82
        $res = [
83
            'method' => self::METHOD_PerformTransaction,
84
            'amount' => $par['amount'],
85
            'transactionId' => $par['transactionId'],
86
            'transactionTime' => $par['transactionTime'],
87
            'key' => $par['parameters']['paramValue']
88
        ];
89
        $this->params = array_merge($this->params, $res);
90
    }
91 View Code Duplication
    public function paramsCheckTransaction($par){
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
92
        $res = [
93
            'method' => self::METHOD_CheckTransaction,
94
            'transactionId' => $par['transactionId'],
95
            'transactionTime' => $par['transactionTime'],
96
        ];
97
        $this->params = array_merge($this->params, $res);
98
    }
99
100
    private function paramsStament($par)
101
    {
102
        $res = [
103
            'method' => self::METHOD_GetStatement,
104
            'dateFrom' => $par['dateFrom'],
105
            'dateTo' => $par['dateTo']
106
        ];
107
        $this->params = array_merge($this->params, $res);
108
    }
109
110 View Code Duplication
    private function paramsCancel($par)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
111
    {
112
        $res = [
113
            'method' => self::METHOD_CancelTransaction,
114
            'transactionId' => $par['transactionId'],
115
            'transactionTime' => $par['transactionTime']
116
        ];
117
        $this->params = array_merge($this->params, $res);
118
    }
119
120
    private function paramsInformation($par)
121
    {
122
        $res = [
123
            'method' => self::METHOD_GetInformation,
124
            'key' => $par['parameters']['paramValue']
125
        ];
126
        $this->params = array_merge($this->params, $res);
127
    }
128
129
}
130