Completed
Push — develop ( 78fd78...600bfc )
by Quentin
02:41
created

Account::getId()   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 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Majora\Component\OAuth\Entity;
4
5
use Majora\Component\OAuth\Model\AccountInterface;
6
use Majora\Framework\Model\CollectionableInterface;
7
use Majora\Framework\Model\CollectionableTrait;
8
use Majora\Framework\Serializer\Model\SerializableTrait;
9
10
/**
11
 * Basic implementation on AccountInterface.
12
 */
13
class Account implements AccountInterface, CollectionableInterface
14
{
15
    use CollectionableTrait, SerializableTrait;
16
17
    /**
18
     * @var int
19
     */
20
    protected $id;
21
22
    /**
23
     * @var int
24
     */
25
    protected $ownerId;
26
27
    /**
28
     * @var string
29
     */
30
    protected $username;
31
32
    /**
33
     * @var string
34
     */
35
    protected $password;
36
37
    /**
38
     * @var string
39
     */
40
    protected $salt;
41
42
    /**
43
     * @var array
44
     */
45
    protected $roles;
46
47
    /**
48
     * @var array
49
     */
50
    protected $applications;
51
52
    /**
53
     * Construct.
54
     *
55
     * @param string $rand
56
     */
57
    public function __construct($rand = 'm@J0raOaUth')
58
    {
59
        $this->salt = base_convert(sha1(uniqid(mt_rand(), true).$rand), 16, 36);
60
        $this->roles = array();
61
    }
62
63
    /**
64
     * @return int
65
     */
66
    public function getId()
67
    {
68
        return $this->id;
69
    }
70
71
    /**
72
     * @see AccountInterface::getOwnerId()
73
     */
74
    public function getOwnerId()
75
    {
76
        return $this->ownerId;
77
    }
78
79
    /**
80
     * Define Account ownerId.
81
     *
82
     * @param int $ownerId
83
     *
84
     * @return self
85
     */
86
    public function setOwnerId($ownerId)
87
    {
88
        $this->ownerId = $ownerId;
89
90
        return $this;
91
    }
92
93
    /**
94
     * @see UserInterface::getUsername()
95
     */
96
    public function getUsername()
97
    {
98
        return $this->username;
99
    }
100
101
    /**
102
     * define Account username.
103
     *
104
     * @param string $username
105
     *
106
     * @return self
107
     */
108
    public function setUsername($username)
109
    {
110
        $this->username = $username;
111
112
        return $this;
113
    }
114
115
    /**
116
     * @see UserInterface::getPassword()
117
     */
118
    public function getPassword()
119
    {
120
        return $this->password;
121
    }
122
123
    /**
124
     * Define Account password.
125
     *
126
     * @param string $password
127
     *
128
     * @return self
129
     */
130
    public function setPassword($password)
131
    {
132
        $this->password = $password;
133
134
        return $this;
135
    }
136
137
    /**
138
     * @see UserInterface::getSalt()
139
     */
140
    public function getSalt()
141
    {
142
        return $this->salt;
143
    }
144
145
    /**
146
     * @see UserInterface::getRoles()
147
     *
148
     * @codeCoverageIgnore
149
     */
150
    public function getRoles()
151
    {
152
        return $this->roles;
153
    }
154
155
    /**
156
     * @see UserInterface::eraseCredentials()
157
     *
158
     * @codeCoverageIgnore
159
     */
160
    public function eraseCredentials()
161
    {
162
        return;
163
    }
164
165
    /**
166
     * @return array
167
     */
168
    public function getApplications()
169
    {
170
        return $this->applications;
171
    }
172
173
    /**
174
     * @param array $applications
175
     */
176
    public function setApplications($applications)
177
    {
178
        $this->applications = $applications;
179
    }
180
181
    public static function getScopes()
182
    {
183
        return array();
184
    }
185
}
186