1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Stinger Soft Platform package. |
5
|
|
|
* |
6
|
|
|
* (c) Oliver Kotte <[email protected]> |
7
|
|
|
* (c) Florian Meyer <[email protected]> |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
10
|
|
|
* file that was distributed with this source code. |
11
|
|
|
*/ |
12
|
|
|
namespace StingerSoft\PlatformBundle\Entity; |
13
|
|
|
|
14
|
|
|
use FOS\UserBundle\Model\User as BaseUser; |
15
|
|
|
use StingerSoft\PlatformBundle\Model\Identifiable; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* |
19
|
|
|
* $LastChangedBy: $ |
20
|
|
|
* $LastChangedDate: $ |
21
|
|
|
* |
22
|
|
|
* Class User |
23
|
|
|
* |
24
|
|
|
* @package StingerSoft\PlatformBundle\Entity |
25
|
|
|
*/ |
26
|
|
|
class User extends BaseUser implements Identifiable { |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* |
30
|
|
|
* @var integer |
31
|
|
|
*/ |
32
|
|
|
protected $id; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* |
36
|
|
|
* @var string |
37
|
|
|
*/ |
38
|
|
|
protected $firstname; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* |
42
|
|
|
* @var string |
43
|
|
|
*/ |
44
|
|
|
protected $surname; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* |
48
|
|
|
* @return string |
49
|
|
|
*/ |
50
|
|
|
public function getFirstname() { |
51
|
|
|
return $this->firstname; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* |
56
|
|
|
* @param string $firstname |
57
|
|
|
* |
58
|
|
|
* @return $this |
59
|
|
|
*/ |
60
|
|
|
public function setFirstname($firstname) { |
61
|
|
|
$this->firstname = $firstname; |
62
|
|
|
|
63
|
|
|
return $this; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* |
68
|
|
|
* @return string |
69
|
|
|
*/ |
70
|
|
|
public function getSurname() { |
71
|
|
|
return $this->surname; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* |
76
|
|
|
* @param string $surname |
77
|
|
|
* |
78
|
|
|
* @return $this |
79
|
|
|
*/ |
80
|
|
|
public function setSurname($surname) { |
81
|
|
|
$this->surname = $surname; |
82
|
|
|
|
83
|
|
|
return $this; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Get realname "Firstname Surname" |
88
|
|
|
* |
89
|
|
|
* @return string |
|
|
|
|
90
|
|
|
*/ |
91
|
|
|
public function getRealName() { |
92
|
|
|
if($this->firstname || $this->surname) { |
93
|
|
|
return trim($this->getFirstname() . ' ' . $this->getSurname()); |
94
|
|
|
} |
95
|
|
|
return null; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* |
100
|
|
|
* @return string - "Username" ("Firstname Surname") |
101
|
|
|
*/ |
102
|
|
|
public function getUsernameAndRealName() { |
103
|
|
|
return $this->getUsername() . ' (' . $this->getRealName() . ')'; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* |
108
|
|
|
* @return string "Surname, Firstname"|"Surname" |
109
|
|
|
*/ |
110
|
|
|
public function getReversedRealName() { |
111
|
|
|
if($this->getFirstname()) { |
112
|
|
|
return $this->getSurname() . ', ' . $this->getFirstname(); |
113
|
|
|
} else { |
114
|
|
|
return $this->getSurname(); |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* |
120
|
|
|
* @return string "Firstname Surname"|"Username" |
121
|
|
|
*/ |
122
|
|
|
public function __toString() { |
123
|
|
|
return $this->getRealName() != null ? $this->getRealName() : $this->getUsername(); |
|
|
|
|
124
|
|
|
} |
125
|
|
|
} |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.