Session::setUserIdKey()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
namespace Sesshin\User;
3
4
use Sesshin\Session as BaseSession;
5
6
class Session extends BaseSession
7
{
8
    private $userIdKey = '_user_id';
9
10
    /**
11
     * @param string $userIdKey
12
     */
13
    public function setUserIdKey($userIdKey)
14
    {
15
        $this->userIdKey = $userIdKey;
16
    }
17
18
    /**
19
     * @return string
20
     */
21
    public function getUserIdKey()
22
    {
23
        return $this->userIdKey;
24
    }
25
26
    /**
27
     * @return mixed
28
     */
29
    public function getUserId()
30
    {
31
        return $this->getValue($this->getUserIdKey());
32
    }
33
34
    /**
35
     * @param string $userId
36
     */
37
    public function login($userId)
38
    {
39
        $this->setValue($this->getUserIdKey(), $userId);
40
    }
41
42
    /**
43
     * @return bool
44
     */
45
    public function isLogged()
46
    {
47
        return !is_null($this->getUserId());
48
    }
49
50
    /**
51
     */
52
    public function logout()
53
    {
54
        $this->unsetValue($this->getUserIdKey());
55
    }
56
}
57