Passed
Push — master ( 6151ba...17a32e )
by Chauncey
52s queued 10s
created

AuthenticatableTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 90
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 90
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getAuthId() 0 5 1
A getAuthIdentifier() 0 5 1
A getAuthPassword() 0 5 1
A getAuthLoginToken() 0 5 1
A setAuthLoginToken() 0 5 1
getAuthIdKey() 0 1 ?
getAuthIdentifierKey() 0 1 ?
getAuthPasswordKey() 0 1 ?
getAuthLoginTokenKey() 0 1 ?
1
<?php
2
3
namespace Charcoal\User\Access;
4
5
/**
6
 * An implementation, as Trait, of the {@see \Charcoal\User\Access\AuthenticatableInterface}.
7
 *
8
 * Trait expects class to implement {@see \ArrayAccess}.
9
 */
10
trait AuthenticatableTrait
11
{
12
    /**
13
     * Retrieve the unique ID for the user.
14
     *
15
     * @return mixed
16
     */
17
    public function getAuthId()
18
    {
19
        $key = $this->getAuthIdKey();
20
        return $this[$key];
21
    }
22
23
    /**
24
     * Retrieve the login ID for the user.
25
     *
26
     * @return mixed
27
     */
28
    public function getAuthIdentifier()
29
    {
30
        $key = $this->getAuthIdentifierKey();
31
        return $this[$key];
32
    }
33
34
    /**
35
     * Retrieve the password for the user.
36
     *
37
     * @return string|null
38
     */
39
    public function getAuthPassword()
40
    {
41
        $key = $this->getAuthPasswordKey();
42
        return $this[$key];
43
    }
44
45
    /**
46
     * Retrieve the login token for the user.
47
     *
48
     * @return string|null
49
     */
50
    public function getAuthLoginToken()
51
    {
52
        $key = $this->getAuthLoginTokenKey();
53
        return $this[$key];
54
    }
55
56
    /**
57
     * Set the token value for the login token.
58
     *
59
     * @param  string $value The token value.
60
     * @return void
61
     */
62
    public function setAuthLoginToken($value)
63
    {
64
        $key = $this->getAuthLoginTokenKey();
65
        $this[$key] = $value;
66
    }
67
68
    /**
69
     * Retrieve the name of the unique ID for the user.
70
     *
71
     * @return string
72
     */
73
    abstract public function getAuthIdKey();
74
75
    /**
76
     * Retrieve the name of the login username for the user.
77
     *
78
     * @return string
79
     */
80
    abstract public function getAuthIdentifierKey();
81
82
    /**
83
     * Retrieve the name of the login password for the user.
84
     *
85
     * Typically, "password".
86
     *
87
     * @return string
88
     */
89
    abstract public function getAuthPasswordKey();
90
91
    /**
92
     * Retrieve the name of the login token for the user.
93
     *
94
     * Typically, "login_token" or "remember_token".
95
     *
96
     * @return string
97
     */
98
    abstract public function getAuthLoginTokenKey();
99
}
100