Completed
Push — orm ( df18d5 )
by
unknown
06:37
created

Account   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 145
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 11
c 2
b 0
f 1
lcom 0
cbo 0
dl 0
loc 145
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getId() 0 4 1
A getOwnerId() 0 4 1
A setOwnerId() 0 6 1
A getUsername() 0 4 1
A setUsername() 0 6 1
A getPassword() 0 4 1
A setPassword() 0 6 1
A getSalt() 0 4 1
A getRoles() 0 4 1
A eraseCredentials() 0 4 1
1
<?php
2
3
namespace Majora\Component\OAuth\Entity;
4
5
use Majora\Component\OAuth\Model\AccountInterface;
6
7
/**
8
 * Basic implementation on AccountInterface.
9
 */
10
class Account implements AccountInterface
11
{
12
    /**
13
     * @var int
14
     */
15
    protected $id;
16
17
    /**
18
     * @var int
19
     */
20
    protected $ownerId;
21
22
    /**
23
     * @var string
24
     */
25
    protected $username;
26
27
    /**
28
     * @var string
29
     */
30
    protected $password;
31
32
    /**
33
     * @var string
34
     */
35
    protected $salt;
36
37
    /**
38
     * @var array
39
     */
40
    protected $roles;
41
42
    /**
43
     * Construct.
44
     *
45
     * @param string $rand
46
     */
47
    public function __construct($rand = 'm@J0raOaUth')
48
    {
49
        $this->salt = base_convert(sha1(uniqid(mt_rand(), true).$rand), 16, 36);
50
        $this->roles = array();
51
    }
52
53
    /**
54
     * @return int
55
     */
56
    public function getId()
57
    {
58
        return $this->id;
59
    }
60
61
    /**
62
     * @see AccountInterface::getOwnerId()
63
     */
64
    public function getOwnerId()
65
    {
66
        return $this->ownerId;
67
    }
68
69
    /**
70
     * Define Account ownerId.
71
     *
72
     * @param int $ownerId
73
     *
74
     * @return self
75
     */
76
    public function setOwnerId($ownerId)
77
    {
78
        $this->ownerId = $ownerId;
79
80
        return $this;
81
    }
82
83
    /**
84
     * @see UserInterface::getUsername()
85
     */
86
    public function getUsername()
87
    {
88
        return $this->username;
89
    }
90
91
    /**
92
     * define Account username.
93
     *
94
     * @param string $username
95
     *
96
     * @return self
97
     */
98
    public function setUsername($username)
99
    {
100
        $this->username = $username;
101
102
        return $this;
103
    }
104
105
    /**
106
     * @see UserInterface::getPassword()
107
     */
108
    public function getPassword()
109
    {
110
        return $this->password;
111
    }
112
113
    /**
114
     * Define Account password.
115
     *
116
     * @param string $password
117
     *
118
     * @return self
119
     */
120
    public function setPassword($password)
121
    {
122
        $this->password = $password;
123
124
        return $this;
125
    }
126
127
    /**
128
     * @see UserInterface::getSalt()
129
     */
130
    public function getSalt()
131
    {
132
        return $this->salt;
133
    }
134
135
    /**
136
     * @see UserInterface::getRoles()
137
     *
138
     * @codeCoverageIgnore
139
     */
140
    public function getRoles()
141
    {
142
        return $this->roles;
143
    }
144
145
    /**
146
     * @see UserInterface::eraseCredentials()
147
     *
148
     * @codeCoverageIgnore
149
     */
150
    public function eraseCredentials()
151
    {
152
        return;
153
    }
154
}
155