<?php
namespace App\Entity\ContentDistribution\AgenturFuerArbeit;
use App\Entity\RecurrentJob;
use App\Utility\DateTimeUtility;
use App\Utility\ReflectionHelper;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use InvalidArgumentException;
/**
* @ORM\Entity
*
* @ORM\Table(
* name="recurrent_job_afa_categorization_requests"
* )
*/
class RecurrentJobAfaCategorizationRequest
{
public const SOURCE_GENERATE_AFA_FEED_COMMAND = 0;
public const SOURCE_DEVHELPER_COMMAND = 1;
public const SOURCE_MIGRATE_FROM_PROFESSIONS_V2_COMMAND = 2;
public function __construct(
RecurrentJob $recurrentJob,
int $source
) {
if (!ReflectionHelper::hasConstWithValue(
self::class,
'SOURCE_',
$source)
) {
throw new InvalidArgumentException("Value '$source' not allowed for source.");
}
$this->recurrentJob = $recurrentJob;
$this->source = $source;
$this->createdAt = DateTimeUtility::createDateTimeUtc();
}
/**
* @ORM\OneToOne(targetEntity="App\Entity\RecurrentJob", cascade={"persist"})
*
* @ORM\JoinColumn(name="recurrent_jobs_id", referencedColumnName="id", onDelete="CASCADE")
*
* @ORM\Id
*/
private RecurrentJob $recurrentJob;
public function getRecurrentJob(): RecurrentJob
{
return $this->recurrentJob;
}
/**
* @ORM\Column(name="created_at", type="datetime", nullable=false)
*/
private DateTime $createdAt;
/**
* @ORM\Column(name="source", type="smallint", nullable=false, options={"unsigned": true})
*/
private int $source;
public function setSource(int $source): void
{
if (!ReflectionHelper::hasConstWithValue(
self::class,
'SOURCE_',
$source)
) {
throw new InvalidArgumentException("Value '$source' not allowed for source.");
}
$this->source = $source;
}
}