Token   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 140
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 12
c 0
b 0
f 0
lcom 2
cbo 2
dl 0
loc 140
ccs 29
cts 29
cp 1
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 2
A getHash() 0 4 1
A setHash() 0 4 1
A setDetails() 0 4 1
A getDetails() 0 4 1
A getTargetUrl() 0 4 1
A setTargetUrl() 0 4 1
A getAfterUrl() 0 4 1
A setAfterUrl() 0 4 1
A getGatewayName() 0 4 1
A setGatewayName() 0 4 1
1
<?php
2
3
namespace Recca0120\LaravelPayum\Model;
4
5
use Payum\Core\Security\Util\Random;
6
use Illuminate\Database\Eloquent\Model;
7
use Payum\Core\Security\TokenInterface;
8
9
class Token extends Model implements TokenInterface
10
{
11
    /**
12
     * $incrementing.
13
     *
14
     * @var bool
15
     */
16
    public $incrementing = false;
17
    /**
18
     * $table.
19
     *
20
     * @var string
21
     */
22
    protected $table = 'payum_tokens';
23
24
    /**
25
     * $primaryKey.
26
     *
27
     * @var string
28
     */
29
    protected $primaryKey = 'hash';
30
31
    /**
32
     * $unguarded.
33
     *
34
     * @var bool
35
     */
36
    protected static $unguarded = true;
37
38
    /**
39
     * __construct.
40
     *
41
     * @param array $attributes
42
     */
43 5
    public function __construct(array $attributes = [])
44
    {
45 5
        $attributes['hash'] = empty($attributes['hash']) === true ? Random::generateToken() : $attributes['hash'];
46 5
        parent::__construct($attributes);
47 5
    }
48
49
    /**
50
     * getHash.
51
     *
52
     * @return string
53
     */
54 1
    public function getHash()
55
    {
56 1
        return $this->getAttribute('hash');
57
    }
58
59
    /**
60
     * setHash.
61
     *
62
     * @param string $hash
63
     */
64 1
    public function setHash($hash)
65
    {
66 1
        $this->setAttribute('hash', $hash);
67 1
    }
68
69
    /**
70
     * setDetails.
71
     *
72
     * @param mixed $details
73
     */
74 1
    public function setDetails($details)
75
    {
76 1
        $this->setAttribute('details', serialize($details));
77 1
    }
78
79
    /**
80
     * getDetails.
81
     *
82
     * @return mixed
83
     */
84 1
    public function getDetails()
85
    {
86 1
        return unserialize($this->getAttribute('details'));
87
    }
88
89
    /**
90
     * getTargetUrl.
91
     *
92
     * @return string
93
     */
94 1
    public function getTargetUrl()
95
    {
96 1
        return $this->getAttribute('targetUrl');
97
    }
98
99
    /**
100
     * setTargetUrl.
101
     *
102
     * @param string $targetUrl
103
     */
104 1
    public function setTargetUrl($targetUrl)
105
    {
106 1
        $this->setAttribute('targetUrl', $targetUrl);
107 1
    }
108
109
    /**
110
     * getAfterUrl.
111
     *
112
     * @return string
113
     */
114 1
    public function getAfterUrl()
115
    {
116 1
        return $this->getAttribute('afterUrl');
117
    }
118
119
    /**
120
     * setAfterUrl.
121
     *
122
     * @param string $afterUrl
123
     */
124 1
    public function setAfterUrl($afterUrl)
125
    {
126 1
        $this->setAttribute('afterUrl', $afterUrl);
127 1
    }
128
129
    /**
130
     * getGatewayName.
131
     *
132
     * @return string
133
     */
134 1
    public function getGatewayName()
135
    {
136 1
        return $this->getAttribute('gatewayName');
137
    }
138
139
    /**
140
     * setGatewayName.
141
     *
142
     * @param string $gatewayName
143
     */
144 1
    public function setGatewayName($gatewayName)
145
    {
146 1
        $this->setAttribute('gatewayName', $gatewayName);
147 1
    }
148
}
149