1 | <?php |
||
17 | class User extends BaseUser implements \JsonSerializable |
||
18 | { |
||
19 | /** |
||
20 | * @ORM\Id |
||
21 | * @ORM\Column(type="integer") |
||
22 | * @ORM\GeneratedValue(strategy="AUTO") |
||
23 | */ |
||
24 | protected $id; |
||
25 | |||
26 | /** |
||
27 | * @ORM\ManyToMany(targetEntity="Overwatch\TestBundle\Entity\TestGroup", inversedBy="users") |
||
28 | * @ORM\JoinTable(name="UsersTestGroups") |
||
29 | */ |
||
30 | protected $groups; |
||
31 | |||
32 | /** |
||
33 | * @ORM\Column(type="string", length=40) |
||
34 | */ |
||
35 | protected $apiKey = null; |
||
36 | |||
37 | /** |
||
38 | * @ORM\Column(type="integer") |
||
39 | */ |
||
40 | protected $alertSetting = AlertSetting::CHANGE; |
||
41 | |||
42 | /** |
||
43 | * @ORM\Column(type="string", length=35, nullable=true) |
||
44 | */ |
||
45 | protected $telephoneNumber = null; |
||
46 | |||
47 | /** |
||
48 | * Constructor |
||
49 | */ |
||
50 | 152 | public function __construct() |
|
55 | |||
56 | /** |
||
57 | * Serialize object to JSON |
||
58 | */ |
||
59 | 13 | public function jsonSerialize() |
|
71 | |||
72 | /** |
||
73 | * Set Email (and username) |
||
74 | * |
||
75 | * @param string $email |
||
76 | * @return User |
||
77 | */ |
||
78 | 152 | public function setEmail($email) |
|
85 | |||
86 | /** |
||
87 | * Get Alert Setting for this user |
||
88 | * |
||
89 | * @return integer $alertSetting |
||
90 | */ |
||
91 | 29 | public function getAlertSetting() |
|
95 | |||
96 | /** |
||
97 | * Set this user's alert setting |
||
98 | * |
||
99 | * @param integer $setting |
||
100 | * @return User |
||
101 | */ |
||
102 | 136 | public function setAlertSetting($setting) |
|
109 | |||
110 | 129 | public function getApiKey() |
|
114 | |||
115 | 143 | public function resetApiKey() |
|
121 | |||
122 | /** |
||
123 | * @ORM\PrePersist() |
||
124 | * @ORM\PreUpdate() |
||
125 | */ |
||
126 | 127 | public function generateApiKey() |
|
134 | |||
135 | /** |
||
136 | * Get this user's telephone number |
||
137 | * |
||
138 | * @return string |
||
139 | */ |
||
140 | 15 | public function getTelephoneNumber() |
|
144 | |||
145 | /** |
||
146 | * Set user's telephone number |
||
147 | * |
||
148 | * @param string $telephoneNumber |
||
149 | * @return User |
||
150 | */ |
||
151 | 136 | public function setTelephoneNumber($telephoneNumber) |
|
157 | |||
158 | /** |
||
159 | * Should this user be alerted for the passed TestResult? |
||
160 | * |
||
161 | * @param TestResult $result |
||
162 | * @return bool |
||
163 | */ |
||
164 | 16 | public function shouldBeAlerted(TestResult $result) |
|
202 | } |
||
203 |