Completed
Push — develop ( 529afd...b3999a )
by Carsten
06:32
created

UserAbstract::__debugInfo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 10
ccs 3
cts 3
cp 1
crap 1
rs 9.9666
c 0
b 0
f 0
1
<?php
2
namespace Germania\Users;
3
4
5
abstract class UserAbstract  implements UserInterface
6
{
7
8
    use UserIdAwareTrait;
9
10
11
    public $display_name;
12
    public $first_name;
13
    public $last_name;
14
    public $login_name;
15
    public $email;
16
    public $api_key;
17
18
    public $is_active;
19
    public $created;
20
    public $updated;
21
22
23
24
    public function __debugInfo() {
25 2
        return [
26
            'ID' => $this->getId(),
27 2
            'FirstName'   => $this->getFirstName(),
28 2
            'LastName'    => $this->getLastName(),
29
            'DisplayName' => $this->getDisplayName(),
30
            'Email'       => $this->getEmail(),
31
            'LoginName'   => $this->getLoginName(),
32
            'isActive'    => $this->isActive(),
33
            'Created'     => $this->getCreationDateTime()->format("Y-m-d H:i:s")
34
        ];
35
    }
36
37 2
38
    /**
39 2
     * Returns the user's full name
40
     */
41
    abstract public function getFullName();
42
43
44
45
    /**
46
     * @return bool
47
     * @uses   $is_active
48
     */
49
    public function isActive()
50
    {
51
        return (bool) $this->is_active;
52
    }
53
54
55
    /**
56
     * @return DateTime
0 ignored issues
show
Bug introduced by
The type Germania\Users\DateTime was not found. Did you mean DateTime? If so, make sure to prefix the type with \.
Loading history...
57 8
     */
58
    public function getCreationDateTime()
59 8
    {
60 8
        if ($this->created)
61
            return \DateTime::createFromFormat( "Y-m-d H:i:s", $this->created );
0 ignored issues
show
Bug Best Practice introduced by
The expression return DateTime::createF...H:i:s', $this->created) returns the type false|DateTime which is incompatible with the documented return type Germania\Users\DateTime.
Loading history...
62
        return $this->created;
63
    }
64
65
66
    /**
67
     * @return DateTime
68
     */
69 8
    public function getLastUpdateDateTime()
70
    {
71 8
        if ($this->updated)
72
            return \DateTime::createFromFormat( "Y-m-d H:i:s", $this->updated );
0 ignored issues
show
Bug Best Practice introduced by
The expression return DateTime::createF...H:i:s', $this->updated) returns the type false|DateTime which is incompatible with the documented return type Germania\Users\DateTime.
Loading history...
73
        return $this->updated;
74
75
    }
76
77
78
    /**
79
     * @uses $display_name
80
     */
81
    public function setDisplayName($display_name)
82
    {
83
        $this->display_name = $display_name;
84
        return $this;
85
    }
86
87 2
88
89 2
    /**
90 2
     * @return string
91
     * @uses   $display_name
92
     */
93
    public function getDisplayName()
94
    {
95
        return $this->display_name;
96
    }
97 2
98
99 2
100
101
102
103
104
105
106
    /**
107
     * @param  string $name
108
     * @return self
109
     * @uses   $first_name
110 2
     */
111
    public function setFirstName($name)
112 2
    {
113 2
        $this->first_name = $name;
114
        return $this;
115
    }
116
117
118
    /**
119
     * @uses $first_name
120 2
     */
121
    public function getFirstName()
122 2
    {
123
        return $this->first_name;
124
    }
125
126
127
128
129
    /**
130
     * @param  string $name
131
     * @return self
132
     * @uses   $last_name
133 8
     */
134
    public function setLastName($name)
135 8
    {
136 8
        $this->last_name = $name;
137
        return $this;
138
    }
139
140
141
    /**
142
     * @uses $last_name
143 4
     */
144
    public function getLastName()
145 4
    {
146
        return $this->last_name;
147
    }
148
149
150
151
152
    /**
153
     * @param  string $name
154
     * @return self
155
     * @uses   $login_name
156 2
     */
157
    public function setLoginName($name)
158 2
    {
159 2
        $this->login_name = $name;
160
        return $this;
161
    }
162
163
164
    /**
165
     * @uses $login_name
166 2
     */
167
    public function getLoginName()
168 2
    {
169
        return $this->login_name;
170
    }
171
172
173
174
175
176
    /**
177
     * @param  mixed $email
178
     * @return self
179
     */
180
    public function setEmail( $email)
181 2
    {
182
        $this->email = $email;
183 2
        return $this;
184
    }
185
186
187
    /**
188
     * @uses $email
189
     */
190
    public function getEmail()
191
    {
192
        return $this->email;
193 2
    }
194
195 2
196 2
197
    /**
198
     * Returns the users API key (if defined)
199
     *
200
     * @return string|null
201
     * @uses   $api_key
202
     */
203
    public function getApiKey()
204
    {
205
        return $this->api_key;
206
    }
207
208
209
210
    /**
211
     * Sets the users API key
212
     *
213
     * @return self
214
     * @uses   $api_key
215
     */
216
    public function setApiKey( $key )
217
    {
218
        $this->api_key = $key;
219
        return $this;
220
    }
221
222
223
224
}
225