Completed
Pull Request — master (#72)
by Thibaud
08:29
created

User::getLocale()   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 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
/*
4
 * This file is part of Phraseanet SDK.
5
 *
6
 * (c) Alchemy <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace PhraseanetSDK\Entity;
13
14
use PhraseanetSDK\Annotation\ApiField as ApiField;
15
use PhraseanetSDK\Annotation\Id as Id;
16
17
class User
18
{
19
20
    public static function fromList(array $values)
21
    {
22
        $users = array();
23
24
        foreach ($values as $value) {
25
            $users[$value->id] = self::fromValue($value);
26
        }
27
28
        return $users;
29
    }
30
31 5
    public static function fromValue(\stdClass $value)
32
    {
33 5
        return new self($value);
34
    }
35
36
    /**
37
     * @var \stdClass
38
     */
39
    protected $source;
40
41
    /**
42
     * @ApiField(bind_to="updated_on", type="date")
43
     */
44
    protected $updatedOn;
45
46
    /**
47
     * @ApiField(bind_to="created_on", type="date")
48
     */
49
    protected $createdOn;
50
51
    /**
52
     * @ApiField(bind_to="last_connection", type="date")
53
     */
54
    protected $lastConnection;
55
56
    /**
57
     * @var array
58
     */
59
    protected $collectionRights = array();
60
61
    /**
62
     * @var bool
63
     */
64
    protected $hasCollectionRights = false;
65
66
    /**
67
     * @var array
68
     */
69
    protected $collectionDemands = array();
70
71
    /**
72
     * @var bool
73
     */
74
    protected $hasCollectionDemands = false;
75
76
    /**
77
     * @param \stdClass $source
78
     */
79 5
    public function __construct(\stdClass $source)
80
    {
81 5
        $this->source = $source;
82 5
    }
83
84
    /**
85
     * @return \stdClass
86
     */
87
    public function getRawData()
88
    {
89
        return $this->source;
90
    }
91
92
    /**
93
     * @return string
94
     */
95
    public function getAddress()
96
    {
97
        return $this->source->address;
98
    }
99
100
    /**
101
     * @param string $address
102
     */
103
    public function setAddress($address)
104
    {
105
        $this->source->address = $address;
106
    }
107
108
    /**
109
     * @return string
110
     */
111
    public function getCity()
112
    {
113
        return $this->source->city;
114
    }
115
116
    /**
117
     * @param string $city
118
     */
119
    public function setCity($city)
120
    {
121
        $this->source->city = $city;
122
    }
123
124
    /**
125
     * @return string
126
     */
127
    public function getCompany()
128
    {
129
        return $this->source->company;
130
    }
131
132
    /**
133
     * @param string $company
134
     */
135
    public function setCompany($company)
136
    {
137
        $this->source->company = $company;
138
    }
139
140
    /**
141
     * @return string
142
     */
143
    public function getCountry()
144
    {
145
        return $this->source->country;
146
    }
147
148
    /**
149
     * @param string $country
150
     */
151
    public function setCountry($country)
152
    {
153
        $this->source->country = $country;
154
    }
155
156
    /**
157
     * @return \DateTime
158
     */
159
    public function getCreatedOn()
160
    {
161
        return $this->createdOn ?: $this->createdOn = new \DateTime($this->source->created_on);
162
    }
163
164
    /**
165
     * @param \DateTime $createdOn
166
     */
167
    public function setCreatedOn($createdOn)
168
    {
169
        $this->createdOn = $createdOn;
170
    }
171
172
    /**
173
     * @return string
174
     */
175
    public function getDisplayName()
176
    {
177
        return $this->source->display_name;
178
    }
179
180
    /**
181
     * @param string $displayName
182
     */
183 5
    public function setDisplayName($displayName)
184
    {
185 5
        $this->source->display_name = $displayName;
186
    }
187
188
    /**
189
     * @return string
190
     */
191
    public function getEmail()
192
    {
193
        return $this->source->email;
194
    }
195
196
    /**
197
     * @param string $email
198
     */
199
    public function setEmail($email)
200
    {
201
        $this->source->email = $email;
202
    }
203
204
    /**
205
     * @return string
206
     */
207
    public function getFax()
208
    {
209
        return $this->source->fax;
210
    }
211
212
    /**
213
     * @param string $fax
214
     */
215
    public function setFax($fax)
216
    {
217
        $this->source->fax = $fax;
218
    }
219
220
    /**
221
     * @return string
222
     */
223
    public function getFirstName()
224
    {
225
        return $this->source->first_name;
226
    }
227
228
    /**
229
     * @param string $firstName
230
     */
231
    public function setFirstName($firstName)
232
    {
233
        $this->source->first_name = $firstName;
234
    }
235
236
    /**
237
     * @return string
238
     */
239
    public function getGender()
240
    {
241
        return $this->source->gender;
242
    }
243
244
    /**
245
     * @param string $gender
246
     */
247
    public function setGender($gender)
248
    {
249
        $this->source->gender = $gender;
250
    }
251
252
    /**
253
     * @return string
254
     */
255
    public function getGeonameId()
256
    {
257
        return $this->source->geoname_id;
258
    }
259
260
    /**
261
     * @param string $geonameId
262
     */
263
    public function setGeonameId($geonameId)
264
    {
265
        $this->source->geoname_id = $geonameId;
266
    }
267
268
    /**
269
     * @return int
270
     */
271
    public function getId()
272
    {
273
        return $this->source->id;
274
    }
275
276
    /**
277
     * @param int $id
278
     */
279
    public function setId($id)
280
    {
281
        $this->source->id = $id;
282
    }
283
284
    /**
285
     * @return string
286
     */
287
    public function getJob()
288
    {
289
        return $this->source->job;
290
    }
291
292
    /**
293
     * @param string $job
294
     */
295
    public function setJob($job)
296
    {
297
        $this->source->job = $job;
298
    }
299
300
    /**
301
     * @return \DateTime
302
     */
303
    public function getLastConnection()
304
    {
305
        return $this->lastConnection ?: $this->lastConnection = new \DateTime($this->source->last_connection);
306
    }
307
308
    /**
309
     * @param \DateTime $lastConnection
310
     */
311
    public function setLastConnection($lastConnection)
312
    {
313
        $this->lastConnection = $lastConnection;
314
    }
315
316
    /**
317
     * @return string
318
     */
319
    public function getLastName()
320
    {
321
        return $this->source->last_name;
322
    }
323
324
    /**
325
     * @param string $lastName
326
     */
327
    public function setLastName($lastName)
328
    {
329
        $this->source->last_name = $lastName;
330
    }
331
332
    /**
333
     * @return string
334
     */
335
    public function getLocale()
336
    {
337
        return $this->source->locale;
338
    }
339
340
    /**
341
     * @param string $locale
342
     */
343 5
    public function setLocale($locale)
344
    {
345 5
        $this->source->locale = $locale;
346
    }
347
348
    /**
349
     * @return string
350
     */
351
    public function getLogin()
352
    {
353
        return $this->source->login;
354
    }
355
356
    /**
357
     * @param string $login
358
     */
359
    public function setLogin($login)
360
    {
361
        $this->source->login = $login;
362
    }
363
364
    /**
365
     * @return string
366
     */
367
    public function getPhone()
368
    {
369
        return $this->source->phone;
370
    }
371
372
    /**
373
     * @param string $phone
374
     */
375
    public function setPhone($phone)
376
    {
377
        $this->source->phone = $phone;
378
    }
379
380
    /**
381
     * @return string
382
     */
383
    public function getPosition()
384
    {
385
        return $this->source->position;
386
    }
387
388
    /**
389
     * @param string $position
390
     */
391
    public function setPosition($position)
392
    {
393
        $this->source->position = $position;
394
    }
395
396
    /**
397
     * @return \DateTime
398
     */
399
    public function getUpdatedOn()
400
    {
401
        return $this->updatedOn ?: $this->updatedOn = new \DateTime($this->source->updated_on);
402
    }
403
404
    /**
405
     * @param \DateTime $updatedOn
406
     */
407
    public function setUpdatedOn($updatedOn)
408
    {
409
        $this->updatedOn = $updatedOn;
410
    }
411
412
    /**
413
     * @return string
414
     */
415
    public function getZipCode()
416
    {
417
        return $this->source->zip_code;
418
    }
419
420
    /**
421
     * @param string $zipCode
422
     */
423
    public function setZipCode($zipCode)
424
    {
425
        $this->source->zip_code = $zipCode;
426
    }
427
428
    /**
429
     * @param array $collectionRights
430
     */
431
    public function setCollectionRights(array $collectionRights)
432
    {
433
        $this->collectionRights = $collectionRights;
434
        $this->hasCollectionRights = true;
435
    }
436
437
    /**
438
     * @return array
439
     */
440
    public function getCollectionRights()
441
    {
442
        return $this->collectionRights;
443
    }
444
445
    /**
446
     * @return bool
447
     */
448
    public function hasCollectionRights()
449
    {
450
        return $this->hasCollectionRights;
451
    }
452
453
454
    /**
455
     * @param array $collectionDemands
456
     */
457
    public function setCollectionDemands(array $collectionDemands)
458
    {
459
        $this->collectionDemands = $collectionDemands;
460
        $this->hasCollectionDemands = true;
461
    }
462
463
    /**
464
     * @return array
465
     */
466
    public function getCollectionDemands()
467
    {
468
        return $this->collectionDemands;
469
    }
470
471
    /**
472
     * @return bool
473
     */
474
    public function hasCollectionDemands()
475
    {
476
        return $this->hasCollectionDemands;
477
    }
478
}
479