<?php
namespace App\Entity;
use App\Utility\GuidUtility;
use App\Utility\ReflectionHelper;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use InvalidArgumentException;
/**
* @ORM\Entity
*
* @ORM\Table(
* name="entity_gauges",
* uniqueConstraints={
*
* @ORM\UniqueConstraint(name="gauge_type_entity_class_name_entity_id_measured_at_idx", columns={"gauge_type", "entity_class_name", "entity_id", "measured_at"})
* }
* )
*/
class EntityGauge
{
public const GAUGE_TYPE_IS_IN_JOBLIFT_C_FEED = 0;
public const GAUGE_TYPE_IS_IN_JOBRAPIDO_C_FEED = 1;
public const GAUGE_TYPE_IS_IN_TALENTCOM_C_FEED = 2;
public const GAUGE_TYPE_FOUND_IN_JOBLIFT_FEED = 3;
public const GAUGE_TYPE_FOUND_IN_TALENTCOM_FEED = 4;
public const GAUGE_TYPE_POSITION_IN_JOBLIFT_FEED = 5;
public const GAUGE_TYPE_POSITION_IN_TALENTCOM_FEED = 6;
public const GAUGE_TYPE_IS_IN_MEINESTADT_C_FEED = 7;
public const GAUGE_TYPE_IS_IN_STELLENONLINE_C_FEED = 8;
public const GAUGE_TYPE_IS_IN_KIMETA_C_FEED = 9;
public const GAUGE_TYPE_IS_IN_JOBIJOBA_C_FEED = 10;
public const GAUGE_TYPE_IS_IN_WHATJOBS_C_FEED = 11;
public const GAUGE_TYPE_IS_IN_JOOBLE_C_FEED = 12;
public function __construct(
int $gaugeType,
string $entityClassName,
string $entityId,
DateTime $measuredAt,
int $value
) {
if (!ReflectionHelper::hasConstWithValue(self::class, 'GAUGE_TYPE_', $gaugeType)) {
throw new InvalidArgumentException('Value ' . $gaugeType . ' not allowed for $gaugeType.');
}
if (!class_exists($entityClassName)) {
throw new InvalidArgumentException('Class for Entity Gauge creation does not exist.');
}
GuidUtility::validOrThrow($entityId);
$this->gaugeType = $gaugeType;
$this->measuredAt = $measuredAt;
$this->value = $value;
$this->entityClassName = $entityClassName;
$this->entityId = $entityId;
}
/**
* @ORM\GeneratedValue(strategy="CUSTOM")
*
* @ORM\CustomIdGenerator(class="App\Utility\DatabaseIdGenerator")
*
* @ORM\Column(name="id", type="guid")
*
* @ORM\Id
*/
protected string $id;
/**
* @ORM\Column(name="gauge_type", type="smallint", nullable=false)
*/
private int $gaugeType;
/**
* @ORM\Column(name="entity_class_name", type="string", nullable=false)
*/
private string $entityClassName;
/**
* @ORM\Column(name="entity_id", type="guid", nullable=false)
*/
protected string $entityId;
/**
* @ORM\Column(name="measured_at", type="datetime", nullable=false)
*/
private DateTime $measuredAt;
/**
* @ORM\Column(name="value", type="integer", nullable=false)
*/
private int $value;
public function getId(): string
{
return $this->id;
}
public function getGaugeType(): int
{
return $this->gaugeType;
}
public function getEntityClassName(): string
{
return $this->entityClassName;
}
public function getEntityId(): string
{
return $this->entityId;
}
public function getMeasuredAt(): DateTime
{
return $this->measuredAt;
}
public function getValue(): int
{
return $this->value;
}
}