User.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /*
  3. * Copyright (C) 2021 Echedey López Romero <elr@disroot.org>
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. class User {
  19. private string $Id;
  20. private string $Name;
  21. private string $EMail;
  22. private string $Date;
  23. private int $Privileges;
  24. public function __construct(string $Id, string $Name, string $EMail, string $Date, int $Privileges) {
  25. $this->Id = $Id;
  26. $this->Name = $Name;
  27. $this->Date = $Date;
  28. $this->EMail = $EMail;
  29. $this->Privileges = $Privileges;
  30. }
  31. public function GetId(): string {
  32. return $this->Id;
  33. }
  34. public function GetName(): string {
  35. return $this->Name;
  36. }
  37. public function GetEMail(): string {
  38. return $this->EMail;
  39. }
  40. public function GetDate(): string {
  41. return $this->Date;
  42. }
  43. public function GetPrivileges(): int {
  44. return $this->Privileges;
  45. }
  46. private function GetPrivilegesType(): string {
  47. $Type = '';
  48. switch ($this->Privileges) {
  49. case 0:
  50. $Type = 'Administrator';
  51. break;
  52. case 1:
  53. $Type = 'Author';
  54. break;
  55. case 2:
  56. $Type = 'Subscriber';
  57. break;
  58. }
  59. return $Type;
  60. }
  61. public function SetId(string $Id): void {
  62. $this->Id = $Id;
  63. }
  64. public function SetName(string $Name): void {
  65. $this->Name = $Name;
  66. }
  67. public function SetEMail(string $EMail): void {
  68. $this->EMail = $EMail;
  69. }
  70. public function SetDate(string $Date): void {
  71. $this->Date = $Date;
  72. }
  73. public function SetPrivileges(int $Privileges): void {
  74. $this->Privileges = $Privileges;
  75. }
  76. public function Render(): string {
  77. $HTML = '';
  78. $HTML .= '<div>' . PHP_EOL;
  79. $HTML .= '<span>' . $this->Name . ' ('. $this->GetPrivilegesType() .')' . '</span>' . PHP_EOL;
  80. $HTML .= '<span>' . $this->EMail . '</span>' . PHP_EOL;
  81. $HTML .= '<span>' . $this->Date . '</span>' . PHP_EOL;
  82. $HTML .= '</div>' . PHP_EOL;
  83. return $HTML;
  84. }
  85. }