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.

Response   A
last analyzed

Complexity

Total Complexity 15

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 15
lcom 1
cbo 2
dl 0
loc 79
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
C setResult() 0 45 13
A send() 0 9 2
1
<?php
2
3
namespace Goodoneuz\PayUz\Http\Classes\Click;
4
5
use Goodoneuz\PayUz\Models\PaymentSystem;
6
use Goodoneuz\PayUz\Services\PaymentService;
7
use Goodoneuz\PayUz\Http\Classes\PaymentException;
8
use Goodoneuz\PayUz\Services\PaymentSystemService;
9
10
class Response{
11
    
12
    const SUCCESS                       = 0;
13
    const ERROR_SIGN_CHECK              = -1;
14
    const ERROR_INVALID_AMOUNT          = -2;
15
    const ERROR_ACTION_NOT_FOUND        = -3;
16
    const ERROR_ALREADY_PAID            = -4;
17
    const ERROR_ORDER_NOT_FOUND         = -5;
18
    const ERROR_TRANSACTION_NOT_FOUND   = -6;
19
    const ERROR_UPDATE_ORDER            = -7;
20
    const ERROR_REQUEST_FROM            = -8;
21
    const ERROR_TRANSACTION_CANCELLED   = -9;
22
    const ERROR_VENDOR_NOT_FOUND         = -10;
23
    public $result = [];
24
25
    /**
26
     * @param null $status
27
     * @param null $params
28
     * @throws PaymentException
29
     */
30
    public function setResult($status = null, $params = null)
31
    {
32
        $this->result['error'] = $status;
33
        switch ($status) {
34
            case self::SUCCESS:
35
                $this->result['error_note'] = 'Success';
36
                break;
37
            case self::ERROR_SIGN_CHECK:
38
                $this->result['error_note'] = 'Ошибка проверки подписи';
39
                break;
40
            case self::ERROR_INVALID_AMOUNT:
41
                $this->result['error_note'] = 'Неверная сумма оплаты';
42
                break;
43
            case self::ERROR_ACTION_NOT_FOUND:
44
                $this->result['error_note'] = 'Запрашиваемое действие не найдено';
45
                break;
46
            case self::ERROR_ALREADY_PAID:
47
                $this->result['error_note'] = 'Транзакция ранее была подтверждена (при попытке подтвердить или отменить ранее подтвержденную транзакцию)';
48
                break;
49
            case self::ERROR_ORDER_NOT_FOUND:
50
                $this->result['error_note'] = 'Не найдет пользователь/заказ (проверка параметра merchant_trans_id)';
51
                break;
52
            case self::ERROR_TRANSACTION_NOT_FOUND:
53
                $this->result['error_note'] = 'Не найдена транзакция (проверка параметра merchant_prepare_id)';
54
                break;
55
            case self::ERROR_UPDATE_ORDER:
56
                $this->result['error_note'] = 'Ошибка при изменении данных пользователя (изменение баланса счета и т.п.)';
57
                break;
58
            case self::ERROR_REQUEST_FROM:
59
                $this->result['error_note'] = 'Ошибка в запросе от CLICK (переданы не все параметры и т.п.)';
60
                break;
61
            case self::ERROR_TRANSACTION_CANCELLED:
62
                $this->result['error_note'] = 'Транзакция ранее была отменена (При попытке подтвердить или отменить ранее отмененную транзакцию)';
63
                break;
64
            default:
65
                $this->result['error_note'] = 'ERROR_VENDOR_NOT_FOUND';
66
                break;
67
        }
68
        if (is_array($params)){
69
            foreach ($params as $key => $param ){
70
                $this->result[$key] = $param;
71
            }
72
        }
73
        throw new PaymentException($this);
74
    }
75
76
    /**
77
     *
78
     */
79
    public function send(){
80
        $params = PaymentSystemService::getPaymentSystemParamsCollect(PaymentSystem::CLICK);
81
        $timestamp = time();
82
        $digest = sha1($timestamp .  $params['secret_key']);
0 ignored issues
show
Unused Code introduced by
$digest is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
83
        
84
        if(env('APP_ENV') != 'testing')
85
            header('Content-Type: application/json; charset=UTF-8');
86
        echo json_encode($this->result);
87
    }
88
}
89