src/App/Entity/EntityGauge.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Utility\GuidUtility;
  4. use App\Utility\ReflectionHelper;
  5. use DateTime;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use InvalidArgumentException;
  8. /**
  9. * @ORM\Entity
  10. *
  11. * @ORM\Table(
  12. * name="entity_gauges",
  13. * uniqueConstraints={
  14. *
  15. * @ORM\UniqueConstraint(name="gauge_type_entity_class_name_entity_id_measured_at_idx", columns={"gauge_type", "entity_class_name", "entity_id", "measured_at"})
  16. * }
  17. * )
  18. */
  19. class EntityGauge
  20. {
  21. public const GAUGE_TYPE_IS_IN_JOBLIFT_C_FEED = 0;
  22. public const GAUGE_TYPE_IS_IN_JOBRAPIDO_C_FEED = 1;
  23. public const GAUGE_TYPE_IS_IN_TALENTCOM_C_FEED = 2;
  24. public const GAUGE_TYPE_FOUND_IN_JOBLIFT_FEED = 3;
  25. public const GAUGE_TYPE_FOUND_IN_TALENTCOM_FEED = 4;
  26. public const GAUGE_TYPE_POSITION_IN_JOBLIFT_FEED = 5;
  27. public const GAUGE_TYPE_POSITION_IN_TALENTCOM_FEED = 6;
  28. public const GAUGE_TYPE_IS_IN_MEINESTADT_C_FEED = 7;
  29. public const GAUGE_TYPE_IS_IN_STELLENONLINE_C_FEED = 8;
  30. public const GAUGE_TYPE_IS_IN_KIMETA_C_FEED = 9;
  31. public const GAUGE_TYPE_IS_IN_JOBIJOBA_C_FEED = 10;
  32. public const GAUGE_TYPE_IS_IN_WHATJOBS_C_FEED = 11;
  33. public const GAUGE_TYPE_IS_IN_JOOBLE_C_FEED = 12;
  34. public function __construct(
  35. int $gaugeType,
  36. string $entityClassName,
  37. string $entityId,
  38. DateTime $measuredAt,
  39. int $value
  40. ) {
  41. if (!ReflectionHelper::hasConstWithValue(self::class, 'GAUGE_TYPE_', $gaugeType)) {
  42. throw new InvalidArgumentException('Value ' . $gaugeType . ' not allowed for $gaugeType.');
  43. }
  44. if (!class_exists($entityClassName)) {
  45. throw new InvalidArgumentException('Class for Entity Gauge creation does not exist.');
  46. }
  47. GuidUtility::validOrThrow($entityId);
  48. $this->gaugeType = $gaugeType;
  49. $this->measuredAt = $measuredAt;
  50. $this->value = $value;
  51. $this->entityClassName = $entityClassName;
  52. $this->entityId = $entityId;
  53. }
  54. /**
  55. * @ORM\GeneratedValue(strategy="CUSTOM")
  56. *
  57. * @ORM\CustomIdGenerator(class="App\Utility\DatabaseIdGenerator")
  58. *
  59. * @ORM\Column(name="id", type="guid")
  60. *
  61. * @ORM\Id
  62. */
  63. protected string $id;
  64. /**
  65. * @ORM\Column(name="gauge_type", type="smallint", nullable=false)
  66. */
  67. private int $gaugeType;
  68. /**
  69. * @ORM\Column(name="entity_class_name", type="string", nullable=false)
  70. */
  71. private string $entityClassName;
  72. /**
  73. * @ORM\Column(name="entity_id", type="guid", nullable=false)
  74. */
  75. protected string $entityId;
  76. /**
  77. * @ORM\Column(name="measured_at", type="datetime", nullable=false)
  78. */
  79. private DateTime $measuredAt;
  80. /**
  81. * @ORM\Column(name="value", type="integer", nullable=false)
  82. */
  83. private int $value;
  84. public function getId(): string
  85. {
  86. return $this->id;
  87. }
  88. public function getGaugeType(): int
  89. {
  90. return $this->gaugeType;
  91. }
  92. public function getEntityClassName(): string
  93. {
  94. return $this->entityClassName;
  95. }
  96. public function getEntityId(): string
  97. {
  98. return $this->entityId;
  99. }
  100. public function getMeasuredAt(): DateTime
  101. {
  102. return $this->measuredAt;
  103. }
  104. public function getValue(): int
  105. {
  106. return $this->value;
  107. }
  108. }