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.

PaymentSystemService   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 12
lcom 0
cbo 2
dl 0
loc 70
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A createPaymentSystem() 0 10 3
A storeParams() 0 13 4
A updatePaymentSystem() 0 17 3
A getPaymentSystemParamsCollect() 0 12 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Azizbek Eshonaliyev
5
 * Date: 2/22/2019
6
 * Time: 8:31 PM
7
 */
8
9
namespace Goodoneuz\PayUz\Services;
10
11
12
use Illuminate\Support\Facades\DB;
13
use Goodoneuz\PayUz\Models\PaymentSystem;
14
use Goodoneuz\PayUz\Models\PaymentSystemParam;
15
16
class PaymentSystemService
17
{
18
    /**
19
     * @param $request
20
     * @return mixed
21
     */
22
    public static function createPaymentSystem($request)
23
    {
24
        $payment_system = PaymentSystem::create($request->all());
25
26
        if (isset($request['params']) && is_array($request['params']))
27
28
            self::storeParams($request['params'],$payment_system);
29
30
        return $payment_system;
31
    }
32
33
    /**
34
     * @param array $params
35
     * @param $payment_system
36
     */
37
    public static function storeParams(array $params, $payment_system)
38
    {
39
        if (is_array($params) && count($params)>0)
40
            foreach ($params as $param)
41
            {
42
                PaymentSystemParam::create([
43
                    'system'    => $payment_system->system,
44
                    'label'     => $param['label'],
45
                    'name'      => $param['name'],
46
                    'value'     => $param['value']    
47
                ]);
48
            }
49
    }
50
51
    public static function updatePaymentSystem(\Illuminate\Http\Request $request,$payment_system)
52
    {
53
        $payment_system->update([
54
            'name'      => $request['name'],
55
            'system'    => $request['system'],
56
            'status'    => $request['status']
57
        ]);
58
        if (isset($request['params']) && is_array($request['params']))
59
        {
60
            DB::table('payment_system_params')
61
            ->where('system',$request['system'])
62
            ->delete();
63
64
            self::storeParams($request['params'],$payment_system);
65
        }
66
        return $payment_system;
67
    }
68
69
    /**
70
     * @param $driver
71
     * @return array
72
     */
73
    public static function getPaymentSystemParamsCollect($driver)
74
    {
75
        $params = PaymentSystemParam::where('system',$driver)->get();
76
77
        if (count($params)>0)
78
        
79
            return $params->mapWithKeys(function ($item) {
80
                return [$item['name'] => $item['value']];
81
            });
82
83
        return [];
84
    }
85
}
86