Completed
Push — development ( 2fad51...a387f8 )
by Claudio
02:44
created

PaymentMethod   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 125
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 125
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A store() 0 9 1
A getDisclaimerRequiredAttribute() 0 4 1
A getPremiumSmsAttribute() 0 4 1
A getRequestPathAttribute() 0 4 1
A getPurchaseParamsAttribute() 0 4 1
A setPurchaseParams() 0 9 1
A getSmallPrintAttribute() 0 4 1
1
<?php
2
3
namespace App\Models;
4
5
use stdClass;
6
7
/**
8
 * Class PaymentMethod
9
 * @package App\Models
10
 */
11
class PaymentMethod extends ChocolateyModel
12
{
13
    /**
14
     * Disable Timestamps
15
     *
16
     * @var bool
17
     */
18
    public $timestamps = false;
19
20
    /**
21
     * The table associated with the model.
22
     *
23
     * @var string
24
     */
25
    protected $table = 'chocolatey_shop_payment_methods';
26
27
    /**
28
     * Primary Key of the Table
29
     *
30
     * @var string
31
     */
32
    protected $primaryKey = 'id';
33
34
    /**
35
     * Purchase Params
36
     *
37
     * @var array
38
     */
39
    public $purchaseParams = null;
40
41
    /**
42
     * The Appender(s) of the Model
43
     *
44
     * @var array
45
     */
46
    protected $appends = [
47
        'disclaimerRequired',
48
        'premiumSms',
49
        'purchaseParams',
50
        'requestPath',
51
        'smallPrint'
52
    ];
53
54
    /**
55
     * Store an Shop Country
56
     * @param string $methodName
57
     * @param string $code
58
     * @param string $buttonImageUrl
59
     * @param string $buttonText
60
     * @return PaymentMethod
61
     */
62
    public function store(string $methodName, string $code, string $buttonImageUrl, string $buttonText): PaymentMethod
63
    {
64
        $this->attributes['name'] = $methodName;
65
        $this->attributes['buttonLogoUrl'] = $buttonImageUrl;
66
        $this->attributes['buttonText'] = $buttonText;
67
        $this->attributes['localizationKey'] = $code;
68
69
        return $this;
70
    }
71
72
    /**
73
     * Get Disclaimer Required Attribute
74
     *
75
     * @return bool
76
     */
77
    public function getDisclaimerRequiredAttribute(): bool
78
    {
79
        return false;
80
    }
81
82
    /**
83
     * Get Premium SMS Attribute
84
     *
85
     * @return bool
86
     */
87
    public function getPremiumSmsAttribute(): bool
88
    {
89
        return false;
90
    }
91
92
    /**
93
     * Get Request Path Attribute
94
     *
95
     * @return string
96
     */
97
    public function getRequestPathAttribute(): string
98
    {
99
        return 'online';
100
    }
101
102
    /**
103
     * Get the Purchase Params
104
     *
105
     * @return array
106
     */
107
    public function getPurchaseParamsAttribute()
108
    {
109
        return $this->purchaseParams;
110
    }
111
112
    /**
113
     * Set Purchase Params
114
     * @param array $parameters
115
     */
116
    public function setPurchaseParams(array $parameters)
117
    {
118
        $params = new stdClass();
119
        $params->countryId = $parameters[0];
120
        $params->pricePointId = $parameters[1];
121
        $params->paymentMethodId = $this->attributes['id'];
122
123
        $this->purchaseParams = $params;
0 ignored issues
show
Documentation Bug introduced by
It seems like $params of type object<stdClass> is incompatible with the declared type array of property $purchaseParams.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
124
    }
125
126
    /**
127
     * Get Small Print Attribute
128
     *
129
     * @return string
130
     */
131
    public function getSmallPrintAttribute(): string
132
    {
133
        return 'null';
134
    }
135
}
136