src/App/Entity/Blacklisting.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Utility\GuidUtility;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Exception;
  6. /**
  7. * @ORM\Entity
  8. *
  9. * @ORM\Table(
  10. * name="blacklistings",
  11. * indexes={
  12. *
  13. * @ORM\Index(name="email_type_idx", columns={"email", "type"})
  14. * }
  15. * )
  16. */
  17. class Blacklisting
  18. {
  19. public const BLACKLISTING_TYPE_EBAY = 0;
  20. public const BLACKLISTING_TYPE_MAILING = 1;
  21. public const BLACKLISTING_TYPE_REGISTRATION = 2;
  22. public const BLACKLISTING_TYPE_RECRUIT = 3;
  23. public const BLACKLISTING_TYPE_MASS_MAILING = 4;
  24. public const BLACKLISTING_TYPE_JOBRAPIDO = 5;
  25. public const BLACKLISTING_TYPE_JOBLIFT = 6;
  26. public const BLACKLISTING_TYPE_TALENTCOM = 7;
  27. public const BLACKLISTING_TYPE_INDEED = 8;
  28. public const BLACKLISTING_TYPE_KIMETA = 9;
  29. public const BLACKLISTING_TYPE_STELLENONLINE = 10;
  30. public const BLACKLISTING_TYPE_AGENTUR_FUER_ARBEIT = 11;
  31. public const BLACKLISTING_TYPE_ONETIME_LOGIN = 12;
  32. public const BLACKLISTING_TYPE_MEINESTADT = 13;
  33. public const BLACKLISTING_TYPE_JOBIJOBA = 14;
  34. public const BLACKLISTING_TYPE_WHATJOBS = 15;
  35. public const BLACKLISTING_TYPE_SEARCH = 16;
  36. public const BLACKLISTING_TYPE_CONVERSATION_MESSAGES = 17;
  37. public const BLACKLISTING_TYPE_JOOBLE = 18;
  38. public const BLACKLISTING_TYPE_ALLFEEDS = 19;
  39. public const BLACKLISTING_TYPE_STEPSTONE = 20;
  40. public const BLACKLISTING_TYPE_PERSOMATCH = 21;
  41. public const BLACKLISTING_TYPE_XING = 22;
  42. public const BLACKLISTING_TYPES = [
  43. self::BLACKLISTING_TYPE_EBAY,
  44. self::BLACKLISTING_TYPE_MAILING,
  45. self::BLACKLISTING_TYPE_REGISTRATION,
  46. self::BLACKLISTING_TYPE_RECRUIT,
  47. self::BLACKLISTING_TYPE_MASS_MAILING,
  48. self::BLACKLISTING_TYPE_JOBRAPIDO,
  49. self::BLACKLISTING_TYPE_JOBLIFT,
  50. self::BLACKLISTING_TYPE_TALENTCOM,
  51. self::BLACKLISTING_TYPE_INDEED,
  52. self::BLACKLISTING_TYPE_KIMETA,
  53. self::BLACKLISTING_TYPE_STELLENONLINE,
  54. self::BLACKLISTING_TYPE_AGENTUR_FUER_ARBEIT,
  55. self::BLACKLISTING_TYPE_ONETIME_LOGIN,
  56. self::BLACKLISTING_TYPE_MEINESTADT,
  57. self::BLACKLISTING_TYPE_JOBIJOBA,
  58. self::BLACKLISTING_TYPE_WHATJOBS,
  59. self::BLACKLISTING_TYPE_SEARCH,
  60. self::BLACKLISTING_TYPE_CONVERSATION_MESSAGES,
  61. self::BLACKLISTING_TYPE_JOOBLE,
  62. self::BLACKLISTING_TYPE_STEPSTONE,
  63. self::BLACKLISTING_TYPE_PERSOMATCH,
  64. self::BLACKLISTING_TYPE_XING,
  65. self::BLACKLISTING_TYPE_ALLFEEDS
  66. ];
  67. public const BLACKLISTING_TYPES_TO_NAMES = [
  68. self::BLACKLISTING_TYPE_EBAY => 'ebay',
  69. self::BLACKLISTING_TYPE_MAILING => 'mailing',
  70. self::BLACKLISTING_TYPE_REGISTRATION => 'registration',
  71. self::BLACKLISTING_TYPE_RECRUIT => 'recruit',
  72. self::BLACKLISTING_TYPE_MASS_MAILING => 'massmailing',
  73. self::BLACKLISTING_TYPE_JOBRAPIDO => 'jobrapido',
  74. self::BLACKLISTING_TYPE_JOBLIFT => 'joblift',
  75. self::BLACKLISTING_TYPE_TALENTCOM => 'talentcom',
  76. self::BLACKLISTING_TYPE_INDEED => 'indeed',
  77. self::BLACKLISTING_TYPE_KIMETA => 'kimeta',
  78. self::BLACKLISTING_TYPE_STELLENONLINE => 'stellenonline',
  79. self::BLACKLISTING_TYPE_AGENTUR_FUER_ARBEIT => 'agenturfuerarbeit',
  80. self::BLACKLISTING_TYPE_ONETIME_LOGIN => 'onetimelogin',
  81. self::BLACKLISTING_TYPE_MEINESTADT => 'meinestadt',
  82. self::BLACKLISTING_TYPE_JOBIJOBA => 'jobijoba',
  83. self::BLACKLISTING_TYPE_WHATJOBS => 'whatjobs',
  84. self::BLACKLISTING_TYPE_SEARCH => 'suche',
  85. self::BLACKLISTING_TYPE_CONVERSATION_MESSAGES => 'nachrichten',
  86. self::BLACKLISTING_TYPE_JOOBLE => 'jooble',
  87. self::BLACKLISTING_TYPE_STEPSTONE => 'stepstone',
  88. self::BLACKLISTING_TYPE_PERSOMATCH => 'persomatch',
  89. self::BLACKLISTING_TYPE_XING => 'xing',
  90. self::BLACKLISTING_TYPE_ALLFEEDS => 'allfeeds'
  91. ];
  92. public function __construct(string $email, int $type)
  93. {
  94. $this->email = $email;
  95. $this->type = $type;
  96. }
  97. /**
  98. * @var string
  99. *
  100. * @ORM\GeneratedValue(strategy="CUSTOM")
  101. *
  102. * @ORM\CustomIdGenerator(class="App\Utility\DatabaseIdGenerator")
  103. *
  104. * @ORM\Column(name="id", type="guid")
  105. *
  106. * @ORM\Id
  107. */
  108. protected $id;
  109. public function setId(string $id): void
  110. {
  111. GuidUtility::validOrThrow($id);
  112. $this->id = $id;
  113. }
  114. public function getId(): string
  115. {
  116. return $this->id;
  117. }
  118. /**
  119. * @ORM\Column(name="email", type="string", length=1024, nullable=false)
  120. */
  121. protected string $email;
  122. public function setEmail(string $email)
  123. {
  124. $this->email = $email;
  125. }
  126. public function getEmail(): string
  127. {
  128. return $this->email;
  129. }
  130. /**
  131. * @ORM\Column(name="type", type="integer", nullable=false)
  132. */
  133. protected int $type;
  134. /**
  135. * @throws Exception
  136. */
  137. public function setType(int $type)
  138. {
  139. if (!in_array($type, self::BLACKLISTING_TYPES)) {
  140. throw new Exception('Value ' . $type . ' not allowed for type.');
  141. }
  142. $this->type = $type;
  143. }
  144. public function getType(): int
  145. {
  146. return $this->type;
  147. }
  148. }