src/App/Entity/ContentDistribution/IntegratedExternalPartnerCustomerContentDistributionValue.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\ContentDistribution;
  3. use App\Entity\ExternalPartner\IntegratedExternalPartnerCustomer;
  4. use App\Utility\ReflectionHelper;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Exception;
  7. /**
  8. * @ORM\Entity
  9. *
  10. * @ORM\Table(
  11. * name="integrated_external_partner_content_distribution_values"
  12. * )
  13. */
  14. class IntegratedExternalPartnerCustomerContentDistributionValue
  15. {
  16. public const NAME_MAX_USER_CLICKS_ON_RECURRENT_JOB_ON_INDEED_SITE_PER_MONTH_INDEED_AB_FEED = 'maxUserClicksOnRecurrentJobOnIndeedSitePerMonthABFeed';
  17. public const NAME_MAX_USER_CLICKS_ON_RECURRENT_JOB_ON_INDEED_SITE_PER_MONTH_INDEED_C_FEED = 'maxUserClicksOnRecurrentJobOnIndeedSitePerMonthCFeed';
  18. public const NAME_MAX_RECURRENT_JOBS_EBAY_FEED = 'maxRecurrentJobsEbayFeed';
  19. public const NAME_BUSINESS_NAME_EBAY_FEED = 'businessNameEbayFeed';
  20. public const NAME_RELEASED_FOR_TALENTCOM = 'releasedForTalentcom';
  21. public const NAME_RELEASED_FOR_JOBLIFT = 'releasedForJoblift';
  22. public const NAME_RELEASED_FOR_STELLENONLINE = 'releasedForStellenonline';
  23. public const NAME_RELEASED_FOR_MEINESTADT = 'releasedForMeinestadt';
  24. public const NAME_RELEASED_FOR_JOBIJOBA = 'releasedForJobijoba';
  25. public const NAME_RELEASED_FOR_WHATJOBS = 'releasedForWhatjobs';
  26. public const NAME_RELEASED_FOR_INDEED = 'releasedForIndeed';
  27. public const NAME_RELEASED_FOR_AGENTURFUERARBEIT = 'releasedForAgenturfuerarbeit';
  28. public const NAME_RELEASED_FOR_EBAY = 'releasedForEbay';
  29. public const NAME_RELEASED_FOR_PERSOMATCH = 'releasedForPersomatch';
  30. public const NAME_RELEASED_FOR_STEPSTONE = 'releasedForStepstone';
  31. public const NAME_RELEASED_FOR_XING = 'releasedForXing';
  32. public const NAME_KLEINANZEIGEN_IMAGE_EXISTS = 'kleinanzeigenImageExists';
  33. public const NAME_RELEASED_FOR_JOOBLE = 'releasedForJooble';
  34. public const NAME_CPC_TALENTCOM = 'cpcTalentcom';
  35. public const NAME_CPC_JOBLIFT = 'cpcJoblift';
  36. public const NAME_CPC_STELLENONLINE = 'cpcStellenonline';
  37. public const NAME_CPC_MEINESTADT = 'cpcMeinestadt';
  38. public const NAME_CPC_JOBIJOBA = 'cpcJobijoba';
  39. public const NAME_CPC_WHATJOBS = 'cpcWhatjobs';
  40. public const NAME_CPC_INDEED = 'cpcIndeed';
  41. public const NAME_CPC_JOOBLE = 'cpcJooble';
  42. public const NAME_CPC_STEPSTONE = 'cpcStepstone';
  43. public const NAME_CPC_PERSOMATCH = 'cpcPersomatch';
  44. public const NAME_CPC_XING = 'cpcXing';
  45. public const NAME_MAX_RECURRENT_JOBS_INDEED_FEED = 'maxRecurrentJobsIndeedFeed';
  46. public const TYPE_STRING = 0;
  47. public const TYPE_FLOAT = 1;
  48. public const TYPE_BOOL = 2;
  49. public const NAMES_TO_TYPES = [
  50. self::NAME_MAX_USER_CLICKS_ON_RECURRENT_JOB_ON_INDEED_SITE_PER_MONTH_INDEED_AB_FEED => self::TYPE_FLOAT,
  51. self::NAME_MAX_USER_CLICKS_ON_RECURRENT_JOB_ON_INDEED_SITE_PER_MONTH_INDEED_C_FEED => self::TYPE_FLOAT,
  52. self::NAME_MAX_RECURRENT_JOBS_EBAY_FEED => self::TYPE_FLOAT,
  53. self::NAME_BUSINESS_NAME_EBAY_FEED => self::TYPE_STRING,
  54. self::NAME_RELEASED_FOR_TALENTCOM => self::TYPE_BOOL,
  55. self::NAME_RELEASED_FOR_JOBLIFT => self::TYPE_BOOL,
  56. self::NAME_RELEASED_FOR_STELLENONLINE => self::TYPE_BOOL,
  57. self::NAME_RELEASED_FOR_MEINESTADT => self::TYPE_BOOL,
  58. self::NAME_RELEASED_FOR_JOBIJOBA => self::TYPE_BOOL,
  59. self::NAME_RELEASED_FOR_WHATJOBS => self::TYPE_BOOL,
  60. self::NAME_RELEASED_FOR_INDEED => self::TYPE_BOOL,
  61. self::NAME_RELEASED_FOR_AGENTURFUERARBEIT => self::TYPE_BOOL,
  62. self::NAME_RELEASED_FOR_EBAY => self::TYPE_BOOL,
  63. self::NAME_CPC_INDEED => self::TYPE_FLOAT,
  64. self::NAME_CPC_TALENTCOM => self::TYPE_FLOAT,
  65. self::NAME_CPC_WHATJOBS => self::TYPE_FLOAT,
  66. self::NAME_CPC_JOBIJOBA => self::TYPE_FLOAT,
  67. self::NAME_CPC_JOBLIFT => self::TYPE_FLOAT,
  68. self::NAME_CPC_STELLENONLINE => self::TYPE_FLOAT,
  69. self::NAME_CPC_MEINESTADT => self::TYPE_FLOAT,
  70. self::NAME_KLEINANZEIGEN_IMAGE_EXISTS => self::TYPE_BOOL,
  71. self::NAME_MAX_RECURRENT_JOBS_INDEED_FEED => self::TYPE_FLOAT,
  72. self::NAME_CPC_JOOBLE => self::TYPE_FLOAT,
  73. self::NAME_RELEASED_FOR_JOOBLE => self::TYPE_BOOL,
  74. self::NAME_RELEASED_FOR_PERSOMATCH => self::TYPE_BOOL,
  75. self::NAME_RELEASED_FOR_STEPSTONE => self::TYPE_BOOL,
  76. self::NAME_RELEASED_FOR_XING => self::TYPE_BOOL,
  77. self::NAME_CPC_STEPSTONE => self::TYPE_FLOAT,
  78. self::NAME_CPC_PERSOMATCH => self::TYPE_FLOAT,
  79. self::NAME_CPC_XING => self::TYPE_FLOAT
  80. ];
  81. /**
  82. * @ORM\Id
  83. *
  84. * @ORM\Column(type="string", nullable=false)
  85. */
  86. private string $name;
  87. /**
  88. * @ORM\Column(type="string", name="string_value", nullable=true, length=4096)
  89. */
  90. private ?string $stringValue;
  91. /**
  92. * @ORM\Column(type="float", name="float_value", nullable=true)
  93. */
  94. private ?float $floatValue;
  95. /**
  96. * @ORM\Column(type="boolean", name="bool_value", nullable=true)
  97. */
  98. private ?bool $boolValue;
  99. /**
  100. * @ORM\ManyToOne(targetEntity="App\Entity\ExternalPartner\IntegratedExternalPartnerCustomer", inversedBy="contentDistributionValues", cascade={"persist"})
  101. *
  102. * @ORM\Id
  103. *
  104. * @ORM\JoinColumn(name="integrated_external_partner_customer_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  105. */
  106. private IntegratedExternalPartnerCustomer $integratedExternalPartnerCustomer;
  107. /** @throws Exception */
  108. public static function createWithStringValue(
  109. IntegratedExternalPartnerCustomer $integratedExternalPartnerCustomer,
  110. string $name,
  111. string $stringValue
  112. ): self {
  113. if (!ReflectionHelper::hasConstWithValue(self::class, 'NAME_', $name)) {
  114. throw new Exception("Not a name: '{$name}'.");
  115. }
  116. if (self::NAMES_TO_TYPES[$name] !== self::TYPE_STRING) {
  117. throw new Exception("Value type for name {$name} cannot be 'string'.");
  118. }
  119. $distributionValue = new self();
  120. $distributionValue->integratedExternalPartnerCustomer = $integratedExternalPartnerCustomer;
  121. $distributionValue->name = $name;
  122. $distributionValue->stringValue = $stringValue;
  123. return $distributionValue;
  124. }
  125. /** @throws Exception */
  126. public static function createWithFloatValue(
  127. IntegratedExternalPartnerCustomer $integratedExternalPartnerCustomer,
  128. string $name,
  129. float $floatValue
  130. ): self {
  131. $distributionValue = new self();
  132. $distributionValue->integratedExternalPartnerCustomer = $integratedExternalPartnerCustomer;
  133. $distributionValue->name = $name;
  134. $distributionValue->floatValue = $floatValue;
  135. return $distributionValue;
  136. }
  137. /** @throws Exception */
  138. public static function createWithBoolValue(
  139. IntegratedExternalPartnerCustomer $integratedExternalPartnerCustomer,
  140. string $name,
  141. float $boolValue
  142. ): self {
  143. if (!ReflectionHelper::hasConstWithValue(self::class, 'NAME_', $name)) {
  144. throw new Exception("Not a name: '{$name}'.");
  145. }
  146. if (self::NAMES_TO_TYPES[$name] !== self::TYPE_BOOL) {
  147. throw new Exception("Value type for name {$name} cannot be 'float'.");
  148. }
  149. $distributionValue = new self();
  150. $distributionValue->integratedExternalPartnerCustomer = $integratedExternalPartnerCustomer;
  151. $distributionValue->name = $name;
  152. $distributionValue->boolValue = $boolValue;
  153. return $distributionValue;
  154. }
  155. public function getName(): string
  156. {
  157. return $this->name;
  158. }
  159. /** @throws Exception */
  160. public function setStringValue(?string $stringValue): void
  161. {
  162. if (self::NAMES_TO_TYPES[$this->name] !== self::TYPE_STRING) {
  163. throw new Exception("Value type for name {$this->name} cannot be 'string'.");
  164. }
  165. $this->stringValue = $stringValue;
  166. }
  167. public function getStringValue(): ?string
  168. {
  169. return $this->stringValue;
  170. }
  171. /** @throws Exception */
  172. public function setFloatValue(?float $floatValue): void
  173. {
  174. $this->floatValue = $floatValue;
  175. }
  176. public function getFloatValue(): ?float
  177. {
  178. return $this->floatValue;
  179. }
  180. /** @throws Exception */
  181. public function setBoolValue(?bool $boolValue): void
  182. {
  183. if (self::NAMES_TO_TYPES[$this->name] !== self::TYPE_BOOL) {
  184. throw new Exception("Value type for name {$this->name} cannot be 'bool'.");
  185. }
  186. $this->boolValue = $boolValue;
  187. }
  188. public function getBoolValue(): ?bool
  189. {
  190. return $this->boolValue;
  191. }
  192. public function getIntegratedExternalPartnerCustomer(): IntegratedExternalPartnerCustomer
  193. {
  194. return $this->integratedExternalPartnerCustomer;
  195. }
  196. }