AbstractUser.php
1 year ago
Admin.php
7 years ago
AppleCalendarEmployeeConnect.php
1 year ago
Customer.php
2 years ago
Manager.php
7 years ago
Provider.php
1 year ago
AbstractUser.php
432 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AmeliaBooking\Domain\Entity\User; |
| 4 | |
| 5 | use AmeliaBooking\Domain\ValueObjects\DateTime\Birthday; |
| 6 | use AmeliaBooking\Domain\ValueObjects\Json; |
| 7 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; |
| 8 | use AmeliaBooking\Domain\ValueObjects\Picture; |
| 9 | use AmeliaBooking\Domain\ValueObjects\String\Description; |
| 10 | use AmeliaBooking\Domain\ValueObjects\String\Email; |
| 11 | use AmeliaBooking\Domain\ValueObjects\String\Name; |
| 12 | use AmeliaBooking\Domain\ValueObjects\String\Password; |
| 13 | use AmeliaBooking\Domain\ValueObjects\String\Phone; |
| 14 | use AmeliaBooking\Domain\ValueObjects\String\Status; |
| 15 | |
| 16 | /** |
| 17 | * Class AbstractUser |
| 18 | * |
| 19 | * @package AmeliaBooking\Domain\Entity\User |
| 20 | * |
| 21 | */ |
| 22 | abstract class AbstractUser |
| 23 | { |
| 24 | const USER_ROLE_ADMIN = 'admin'; |
| 25 | const USER_ROLE_PROVIDER = 'provider'; |
| 26 | const USER_ROLE_MANAGER = 'manager'; |
| 27 | const USER_ROLE_CUSTOMER = 'customer'; |
| 28 | |
| 29 | /** @var Description */ |
| 30 | private $note; |
| 31 | |
| 32 | /** @var Id */ |
| 33 | private $id; |
| 34 | |
| 35 | /** @var Status */ |
| 36 | private $status; |
| 37 | |
| 38 | /** @var Name */ |
| 39 | protected $firstName; |
| 40 | |
| 41 | /** @var Name */ |
| 42 | protected $lastName; |
| 43 | |
| 44 | /** @var Birthday */ |
| 45 | protected $birthday; |
| 46 | |
| 47 | /** @var Picture */ |
| 48 | protected $picture; |
| 49 | |
| 50 | /** @var Id */ |
| 51 | protected $externalId; |
| 52 | |
| 53 | /** @var Email */ |
| 54 | protected $email; |
| 55 | |
| 56 | /** @var Phone */ |
| 57 | protected $phone; |
| 58 | |
| 59 | /** @var Password */ |
| 60 | private $password; |
| 61 | |
| 62 | /** @var Json */ |
| 63 | private $usedTokens; |
| 64 | |
| 65 | /** @var int */ |
| 66 | private $loginType; |
| 67 | |
| 68 | /** @var Name */ |
| 69 | private $zoomUserId; |
| 70 | |
| 71 | /** @var Name */ |
| 72 | private $countryPhoneIso; |
| 73 | |
| 74 | /** @var Json */ |
| 75 | protected $translations; |
| 76 | |
| 77 | /** @var Json */ |
| 78 | protected $customFields; |
| 79 | |
| 80 | /** @var Name */ |
| 81 | private $appleCalendarId; |
| 82 | |
| 83 | /** |
| 84 | * AbstractUser constructor. |
| 85 | * |
| 86 | * @param Name $firstName |
| 87 | * @param Name $lastName |
| 88 | * @param Email $email |
| 89 | */ |
| 90 | public function __construct( |
| 91 | Name $firstName, |
| 92 | Name $lastName, |
| 93 | Email $email |
| 94 | ) { |
| 95 | $this->firstName = $firstName; |
| 96 | $this->lastName = $lastName; |
| 97 | $this->email = $email; |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * @return Id |
| 102 | */ |
| 103 | public function getId() |
| 104 | { |
| 105 | return $this->id; |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * @param Id $id |
| 110 | */ |
| 111 | public function setId(Id $id) |
| 112 | { |
| 113 | $this->id = $id; |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * @return Status |
| 118 | */ |
| 119 | public function getStatus() |
| 120 | { |
| 121 | return $this->status; |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * @param Status $status |
| 126 | */ |
| 127 | public function setStatus(Status $status) |
| 128 | { |
| 129 | $this->status = $status; |
| 130 | } |
| 131 | |
| 132 | /** |
| 133 | * @return Name |
| 134 | */ |
| 135 | public function getFirstName() |
| 136 | { |
| 137 | return $this->firstName; |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * @param Name $firstName |
| 142 | */ |
| 143 | public function setFirstName(Name $firstName) |
| 144 | { |
| 145 | $this->firstName = $firstName; |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * @return Name |
| 150 | */ |
| 151 | public function getLastName() |
| 152 | { |
| 153 | return $this->lastName; |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * @param Name $lastName |
| 158 | */ |
| 159 | public function setLastName(Name $lastName) |
| 160 | { |
| 161 | $this->lastName = $lastName; |
| 162 | } |
| 163 | |
| 164 | /** |
| 165 | * @return string |
| 166 | */ |
| 167 | public function getFullName() |
| 168 | { |
| 169 | return $this->firstName->getValue() . ' ' . $this->lastName->getValue(); |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * @return Birthday |
| 174 | */ |
| 175 | public function getBirthday() |
| 176 | { |
| 177 | return $this->birthday; |
| 178 | } |
| 179 | |
| 180 | /** |
| 181 | * @param Birthday $birthday |
| 182 | */ |
| 183 | public function setBirthday(Birthday $birthday) |
| 184 | { |
| 185 | $this->birthday = $birthday; |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * @return Picture |
| 190 | */ |
| 191 | public function getPicture() |
| 192 | { |
| 193 | return $this->picture; |
| 194 | } |
| 195 | |
| 196 | /** |
| 197 | * @param Picture $picture |
| 198 | */ |
| 199 | public function setPicture(Picture $picture) |
| 200 | { |
| 201 | $this->picture = $picture; |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * @return ID |
| 206 | */ |
| 207 | public function getExternalId() |
| 208 | { |
| 209 | return $this->externalId; |
| 210 | } |
| 211 | |
| 212 | /** |
| 213 | * @param ID $externalId |
| 214 | */ |
| 215 | public function setExternalId(Id $externalId) |
| 216 | { |
| 217 | $this->externalId = $externalId; |
| 218 | } |
| 219 | |
| 220 | /** |
| 221 | * @return Email |
| 222 | */ |
| 223 | public function getEmail() |
| 224 | { |
| 225 | return $this->email; |
| 226 | } |
| 227 | |
| 228 | /** |
| 229 | * @param Email $email |
| 230 | */ |
| 231 | public function setEmail(Email $email) |
| 232 | { |
| 233 | $this->email = $email; |
| 234 | } |
| 235 | |
| 236 | /** |
| 237 | * @return Phone |
| 238 | */ |
| 239 | public function getPhone() |
| 240 | { |
| 241 | return $this->phone; |
| 242 | } |
| 243 | |
| 244 | /** |
| 245 | * @param Phone $phone |
| 246 | */ |
| 247 | public function setPhone(Phone $phone) |
| 248 | { |
| 249 | $this->phone = $phone; |
| 250 | } |
| 251 | |
| 252 | /** |
| 253 | * Get the user type in a string form |
| 254 | */ |
| 255 | public function getType() |
| 256 | { |
| 257 | return self::USER_ROLE_CUSTOMER; |
| 258 | } |
| 259 | |
| 260 | /** |
| 261 | * @return Description |
| 262 | */ |
| 263 | public function getNote() |
| 264 | { |
| 265 | return $this->note; |
| 266 | } |
| 267 | |
| 268 | /** |
| 269 | * @param Description $note |
| 270 | */ |
| 271 | public function setNote(Description $note) |
| 272 | { |
| 273 | $this->note = $note; |
| 274 | } |
| 275 | |
| 276 | /** |
| 277 | * @return Name |
| 278 | */ |
| 279 | public function getZoomUserId() |
| 280 | { |
| 281 | return $this->zoomUserId; |
| 282 | } |
| 283 | |
| 284 | /** |
| 285 | * @param Name $zoomUserId |
| 286 | */ |
| 287 | public function setZoomUserId(Name $zoomUserId) |
| 288 | { |
| 289 | $this->zoomUserId = $zoomUserId; |
| 290 | } |
| 291 | |
| 292 | /** |
| 293 | * @return Password |
| 294 | */ |
| 295 | public function getPassword() |
| 296 | { |
| 297 | return $this->password; |
| 298 | } |
| 299 | |
| 300 | /** |
| 301 | * @param Password $password |
| 302 | */ |
| 303 | public function setPassword($password) |
| 304 | { |
| 305 | $this->password = $password; |
| 306 | } |
| 307 | |
| 308 | /** |
| 309 | * @return Json |
| 310 | */ |
| 311 | public function getUsedTokens() |
| 312 | { |
| 313 | return $this->usedTokens; |
| 314 | } |
| 315 | |
| 316 | /** |
| 317 | * @param Json $usedTokens |
| 318 | */ |
| 319 | public function setUsedTokens($usedTokens) |
| 320 | { |
| 321 | $this->usedTokens = $usedTokens; |
| 322 | } |
| 323 | |
| 324 | /** |
| 325 | * @return int |
| 326 | */ |
| 327 | public function getLoginType() |
| 328 | { |
| 329 | return $this->loginType; |
| 330 | } |
| 331 | |
| 332 | /** |
| 333 | * @param int $loginType |
| 334 | */ |
| 335 | public function setLoginType($loginType) |
| 336 | { |
| 337 | $this->loginType = $loginType; |
| 338 | } |
| 339 | |
| 340 | /** |
| 341 | * @return Name |
| 342 | */ |
| 343 | public function getCountryPhoneIso() |
| 344 | { |
| 345 | return $this->countryPhoneIso; |
| 346 | } |
| 347 | |
| 348 | /** |
| 349 | * @param Name $countryPhoneIso |
| 350 | */ |
| 351 | public function setCountryPhoneIso(Name $countryPhoneIso) |
| 352 | { |
| 353 | $this->countryPhoneIso = $countryPhoneIso; |
| 354 | } |
| 355 | |
| 356 | /** |
| 357 | * @return Json |
| 358 | */ |
| 359 | public function getTranslations() |
| 360 | { |
| 361 | return $this->translations; |
| 362 | } |
| 363 | |
| 364 | /** |
| 365 | * @param Json $translations |
| 366 | */ |
| 367 | public function setTranslations(Json $translations) |
| 368 | { |
| 369 | $this->translations = $translations; |
| 370 | } |
| 371 | |
| 372 | /** |
| 373 | * @return Json |
| 374 | */ |
| 375 | public function getCustomFields() |
| 376 | { |
| 377 | return $this->customFields; |
| 378 | } |
| 379 | |
| 380 | /** |
| 381 | * @param Json $customFields |
| 382 | */ |
| 383 | public function setCustomFields(Json $customFields) |
| 384 | { |
| 385 | $this->customFields = $customFields; |
| 386 | } |
| 387 | |
| 388 | |
| 389 | /** |
| 390 | * @return Name |
| 391 | */ |
| 392 | public function getAppleCalendarId() |
| 393 | { |
| 394 | return $this->appleCalendarId; |
| 395 | } |
| 396 | |
| 397 | /** |
| 398 | * @param Name $appleCalendarId |
| 399 | */ |
| 400 | public function setAppleCalendarId(Name $appleCalendarId) |
| 401 | { |
| 402 | $this->appleCalendarId = $appleCalendarId; |
| 403 | } |
| 404 | |
| 405 | /** |
| 406 | * @return array |
| 407 | */ |
| 408 | public function toArray() |
| 409 | { |
| 410 | return [ |
| 411 | 'id' => null !== $this->getId() ? $this->getId()->getValue() : null, |
| 412 | 'firstName' => $this->getFirstName()->getValue(), |
| 413 | 'lastName' => $this->getLastName()->getValue(), |
| 414 | 'birthday' => null !== $this->getBirthday() ? $this->getBirthday()->getValue() : null, |
| 415 | 'email' => $this->getEmail() ? $this->getEmail()->getValue() : null, |
| 416 | 'phone' => null !== $this->getPhone() ? $this->getPhone()->getValue() : null, |
| 417 | 'type' => $this->getType(), |
| 418 | 'status' => null !== $this->getStatus() ? $this->getStatus()->getValue() : null, |
| 419 | 'note' => null !== $this->getNote() ? $this->getNote()->getValue() : null, |
| 420 | 'zoomUserId' => null !== $this->getZoomUserId() ? $this->getZoomUserId()->getValue() : null, |
| 421 | 'countryPhoneIso' => null !== $this->getCountryPhoneIso() ? $this->getCountryPhoneIso()->getValue() : null, |
| 422 | 'externalId' => null !== $this->getExternalId() ? $this->getExternalId()->getValue() : null, |
| 423 | 'pictureFullPath' => null !== $this->getPicture() ? $this->getPicture()->getFullPath() : null, |
| 424 | 'pictureThumbPath' => null !== $this->getPicture() ? $this->getPicture()->getThumbPath() : null, |
| 425 | 'translations' => $this->getTranslations() ? $this->getTranslations()->getValue() : null, |
| 426 | 'customFields' => $this->getCustomFields() ? $this->getCustomFields()->getValue() : null, |
| 427 | 'appleCalendarId' => null !== $this->getAppleCalendarId() ? $this->getAppleCalendarId()->getValue() : null, |
| 428 | // 'password' => null !== $this->getPassword() ? $this->getPassword()->getValue() : null |
| 429 | ]; |
| 430 | } |
| 431 | } |
| 432 |