Completed
Push — master ( b335a9...7134ac )
by Karsten
03:19
created

UserRecord::getSessionHash()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * File was created 26.04.2016 17:55
4
 */
5
6
namespace PeekAndPoke\Component\Slumber\Data\Addon\UserRecord;
7
8
use PeekAndPoke\Component\Slumber\Annotation\Slumber;
9
10
/**
11
 * @author Karsten J. Gerber <[email protected]>
12
 */
13
class UserRecord
14
{
15
    /**
16
     * @var string
17
     *
18
     * @Slumber\AsString()
19
     */
20
    private $userId;
21
22
    /**
23
     * @var string
24
     *
25
     * @Slumber\AsString()
26
     */
27
    private $name;
28
29
    /**
30
     * @var string
31
     *
32
     * @Slumber\AsString()
33
     */
34
    private $role;
35
36
    /**
37
     * @var string
38
     *
39
     * @Slumber\AsString()
40
     */
41
    private $ip;
42
43
    /**
44
     * @var string
45
     *
46
     * @Slumber\AsString()
47
     */
48
    private $userAgent;
49
50
    /**
51
     * Use this to store a hashed version of the users session id.
52
     *
53
     * For security reason it is HIGHLY recommended to NOT store the real session id.
54
     *
55
     * @var string
56
     *
57
     * @Slumber\AsString()
58
     */
59
    private $sessionHash;
60
61
    /**
62
     * @return string
63
     */
64
    public function __toString()
65
    {
66
        /** @noinspection MagicMethodsValidityInspection */
67
        return implode(
68
            ', ',
69
            [
70
                $this->name,
71
                $this->userId,
72
                $this->role,
73
                $this->ip,
74
                $this->userAgent,
75
            ]
76
        );
77
    }
78
79
    /**
80
     * @return string
81
     */
82
    public function getUserId()
83
    {
84
        return $this->userId;
85
    }
86
87
    /**
88
     * @param string $userId
89
     *
90
     * @return $this
91
     */
92 28
    public function setUserId($userId)
93
    {
94 28
        $this->userId = $userId;
95
96 28
        return $this;
97
    }
98
99
    /**
100
     * @return string
101
     */
102 5
    public function getName()
103
    {
104 5
        return $this->name;
105
    }
106
107
    /**
108
     * @param string $name
109
     *
110
     * @return $this
111
     */
112 28
    public function setName($name)
113
    {
114 28
        $this->name = $name;
115
116 28
        return $this;
117
    }
118
119
    /**
120
     * @return string
121
     */
122 3
    public function getRole()
123
    {
124 3
        return $this->role;
125
    }
126
127
    /**
128
     * @param string $role
129
     *
130
     * @return $this
131
     */
132 28
    public function setRole($role)
133
    {
134 28
        $this->role = $role;
135
136 28
        return $this;
137
    }
138
139
    /**
140
     * @return string
141
     */
142 3
    public function getIp()
143
    {
144 3
        return $this->ip;
145
    }
146
147
    /**
148
     * @param string $ip
149
     *
150
     * @return $this
151
     */
152 28
    public function setIp($ip)
153
    {
154 28
        $this->ip = $ip;
155
156 28
        return $this;
157
    }
158
159
    /**
160
     * @return string
161
     */
162
    public function getUserAgent()
163
    {
164
        return $this->userAgent;
165
    }
166
167
    /**
168
     * @param string $userAgent
169
     *
170
     * @return $this
171
     */
172 28
    public function setUserAgent($userAgent)
173
    {
174 28
        $this->userAgent = $userAgent;
175
176 28
        return $this;
177
    }
178
179
    /**
180
     * @return string
181
     */
182
    public function getSessionHash() : string
183
    {
184
        return $this->sessionHash;
185
    }
186
187
    /**
188
     * @param string $sessionHash
189
     *
190
     * @return $this
191
     */
192 28
    public function setSessionHash(string $sessionHash)
193
    {
194 28
        $this->sessionHash = $sessionHash;
195
196 28
        return $this;
197
    }
198
}
199