src/App/Entity/ContentDistribution/AgenturFuerArbeit/RecurrentJobAfaCategorizationRequest.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity\ContentDistribution\AgenturFuerArbeit;
  3. use App\Entity\RecurrentJob;
  4. use App\Utility\DateTimeUtility;
  5. use App\Utility\ReflectionHelper;
  6. use DateTime;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use InvalidArgumentException;
  9. /**
  10. * @ORM\Entity
  11. *
  12. * @ORM\Table(
  13. * name="recurrent_job_afa_categorization_requests"
  14. * )
  15. */
  16. class RecurrentJobAfaCategorizationRequest
  17. {
  18. public const SOURCE_GENERATE_AFA_FEED_COMMAND = 0;
  19. public const SOURCE_DEVHELPER_COMMAND = 1;
  20. public const SOURCE_MIGRATE_FROM_PROFESSIONS_V2_COMMAND = 2;
  21. public function __construct(
  22. RecurrentJob $recurrentJob,
  23. int $source
  24. ) {
  25. if (!ReflectionHelper::hasConstWithValue(
  26. self::class,
  27. 'SOURCE_',
  28. $source)
  29. ) {
  30. throw new InvalidArgumentException("Value '$source' not allowed for source.");
  31. }
  32. $this->recurrentJob = $recurrentJob;
  33. $this->source = $source;
  34. $this->createdAt = DateTimeUtility::createDateTimeUtc();
  35. }
  36. /**
  37. * @ORM\OneToOne(targetEntity="App\Entity\RecurrentJob", cascade={"persist"})
  38. *
  39. * @ORM\JoinColumn(name="recurrent_jobs_id", referencedColumnName="id", onDelete="CASCADE")
  40. *
  41. * @ORM\Id
  42. */
  43. private RecurrentJob $recurrentJob;
  44. public function getRecurrentJob(): RecurrentJob
  45. {
  46. return $this->recurrentJob;
  47. }
  48. /**
  49. * @ORM\Column(name="created_at", type="datetime", nullable=false)
  50. */
  51. private DateTime $createdAt;
  52. /**
  53. * @ORM\Column(name="source", type="smallint", nullable=false, options={"unsigned": true})
  54. */
  55. private int $source;
  56. public function setSource(int $source): void
  57. {
  58. if (!ReflectionHelper::hasConstWithValue(
  59. self::class,
  60. 'SOURCE_',
  61. $source)
  62. ) {
  63. throw new InvalidArgumentException("Value '$source' not allowed for source.");
  64. }
  65. $this->source = $source;
  66. }
  67. }