Test Failed
Branch lab/data (a414ec)
by Gabor
07:41
created

UserEntity::getHash()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * WebHemi.
4
 *
5
 * PHP version 7.1
6
 *
7
 * @copyright 2012 - 2018 Gixx-web (http://www.gixx-web.com)
8
 * @license   https://opensource.org/licenses/MIT The MIT License (MIT)
9
 *
10
 * @link http://www.gixx-web.com
11
 */
12
declare(strict_types = 1);
13
14
namespace WebHemi\Data\Entity;
15
16
use WebHemi\DateTime;
17
18
/**
19
 * Class UserEntity
20
 */
21
class UserEntity extends AbstractEntity
22
{
23
    /**
24
     * @var array
25
     */
26
    protected $container = [
27
        'id_user' => null,
28
        'username' => null,
29
        'email' => null,
30
        'password' => null,
31
        'hash' => null,
32
        'is_active' => null,
33
        'is_enabled' => null,
34
        'date_created' => null,
35
        'date_modified' => null,
36
    ];
37
38
    /**
39
     * @param int $identifier
40
     * @return UserEntity
41
     */
42
    public function setUserId(int $identifier) : UserEntity
43
    {
44
        $this->container['id_user'] = $identifier;
45
46
        return $this;
47
    }
48
49
    /**
50
     * @return int|null
51
     */
52
    public function getUserId() : ? int
53
    {
54
        return !is_null($this->container['id_user'])
55
            ? (int) $this->container['id_user']
56
            : null;
57
    }
58
59
    /**
60
     * @param string $userName
61
     * @return UserEntity
62
     */
63
    public function setUsername(string $userName) : UserEntity
64
    {
65
        $this->container['username'] = $userName;
66
67
        return $this;
68
    }
69
70
    /**
71
     * @return null|string
72
     */
73
    public function getUsername() : ? string
74
    {
75
        return $this->container['username'];
76
    }
77
78
    /**
79
     * @param string $email
80
     * @return UserEntity
81
     */
82
    public function setEmail(string $email) : UserEntity
83
    {
84
        $this->container['email'] = $email;
85
86
        return $this;
87
    }
88
89
    /**
90
     * @return null|string
91
     */
92
    public function getEmail() : ? string
93
    {
94
        return $this->container['email'];
95
    }
96
97
    /**
98
     * @param string $password
99
     * @return UserEntity
100
     */
101
    public function setPassword(string $password) : UserEntity
102
    {
103
        $this->container['password'] = $password;
104
105
        return $this;
106
    }
107
108
    /**
109
     * @return null|string
110
     */
111
    public function getPassword() : ? string
112
    {
113
        return $this->container['password'];
114
    }
115
116
    /**
117
     * @param string $hash
118
     * @return UserEntity
119
     */
120
    public function setHash(string $hash) : UserEntity
121
    {
122
        $this->container['hash'] = $hash;
123
124
        return $this;
125
    }
126
127
    /**
128
     * @return null|string
129
     */
130
    public function getHash() : ? string
131
    {
132
        return $this->container['hash'];
133
    }
134
135
    /**
136
     * @param bool $isActive
137
     * @return UserEntity
138
     */
139
    public function setIsActive(bool $isActive) : UserEntity
140
    {
141
        $this->container['is_active'] = $isActive ? 1 : 0;
142
143
        return $this;
144
    }
145
146
    /**
147
     * @return bool
148
     */
149
    public function getIsActive() : bool
150
    {
151
        return !empty($this->container['is_active']);
152
    }
153
154
    /**
155
     * @param bool $isEnabled
156
     * @return UserEntity
157
     */
158
    public function setIsEnabled(bool $isEnabled) : UserEntity
159
    {
160
        $this->container['is_enabled'] = $isEnabled ? 1 : 0;
161
162
        return $this;
163
    }
164
165
    /**
166
     * @return bool
167
     */
168
    public function getIsEnabled() : bool
169
    {
170
        return !empty($this->container['is_enabled']);
171
    }
172
173
    /**
174
     * @param DateTime $dateTime
175
     * @return UserEntity
176
     */
177
    public function setDateCreated(DateTime $dateTime) : UserEntity
178
    {
179
        $this->container['date_created'] = $dateTime->format('Y-m-d H:i:s');
180
181
        return $this;
182
    }
183
184
    /**
185
     * @return null|DateTime
186
     */
187
    public function getDateCreated() : ? DateTime
188
    {
189
        return !empty($this->container['date_created'])
190
            ? new DateTime($this->container['date_created'])
191
            : null;
192
    }
193
194
    /**
195
     * @param DateTime $dateTime
196
     * @return UserEntity
197
     */
198
    public function setDateModified(DateTime $dateTime) : UserEntity
199
    {
200
        $this->container['date_modified'] = $dateTime->format('Y-m-d H:i:s');
201
202
        return $this;
203
    }
204
205
    /**
206
     * @return null|DateTime
207
     */
208
    public function getDateModified() : ? DateTime
209
    {
210
        return !empty($this->container['date_modified'])
211
            ? new DateTime($this->container['date_modified'])
212
            : null;
213
    }
214
}
215