src/Entity/SspEndpoint.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Model\GeoEdge\ScanFrequency;
  4. use DateTime;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Gedmo\Mapping\Annotation as Gedmo;
  7. use InvalidArgumentException;
  8. /**
  9.  * SSP Endpoint entity.
  10.  *
  11.  * @ORM\Table(
  12.  *     name="ssp_endpoints",
  13.  *     uniqueConstraints={
  14.  *          @ORM\UniqueConstraint(name="uk_ssp_endpoint_abbr", columns={"abbr"}),
  15.  *          @ORM\UniqueConstraint(name="uk_ssp_endpoint_name", columns={"name"}),
  16.  *          @ORM\UniqueConstraint(name="uk_ssp_endpoint_endpoint", columns={"endpoint"}),
  17.  *          @ORM\UniqueConstraint(name="uk_ssp_endpoint_ad_id", columns={"ad_id"})
  18.  *     }
  19.  * )
  20.  * @ORM\Entity(repositoryClass="App\Repository\SspEndpointRepository")
  21.  */
  22. class SspEndpoint
  23. {
  24.     /**
  25.      * @var int
  26.      *
  27.      * @ORM\Id()
  28.      * @ORM\GeneratedValue(strategy="AUTO")
  29.      * @ORM\Column(name="id", type="integer", nullable=false)
  30.      */
  31.     private $id;
  32.     /**
  33.      * @var string
  34.      *
  35.      * @ORM\Column(name="abbr", type="string", length=8, nullable=false)
  36.      */
  37.     private $abbr;
  38.     /**
  39.      * @var string
  40.      *
  41.      * @ORM\Column(name="name", type="string", length=64, nullable=false)
  42.      */
  43.     private $name;
  44.     /**
  45.      * @var string
  46.      *
  47.      * @ORM\Column(name="endpoint", type="string", length=255, nullable=false)
  48.      */
  49.     private $endpoint;
  50.     /**
  51.      * @var string
  52.      *
  53.      * @ORM\Column(name="protocol", type="string", length=16, nullable=false)
  54.      */
  55.     private $protocol;
  56.     /**
  57.      * @var int
  58.      *
  59.      * @ORM\Column(name="ad_id", type="integer", nullable=false)
  60.      */
  61.     private $adId;
  62.     /**
  63.      * @var array
  64.      *
  65.      * @ORM\Column(name="countries", type="simple_array", nullable=true)
  66.      */
  67.     private $countries = [];
  68.     /**
  69.      * @var array
  70.      *
  71.      * @ORM\Column(name="device_types", type="simple_array", nullable=true)
  72.      */
  73.     private $deviceTypes = [];
  74.     /**
  75.      * How many times a target should be scanned per day. (GeoEdge times_per_day)
  76.      *
  77.      * @var int
  78.      *
  79.      * @ORM\Column(name="scan_frequency", type="integer", nullable=false, options={"default": 48})
  80.      */
  81.     private $scanFrequency ScanFrequency::TIMES_PER_DAY_SSP;
  82.     /**
  83.      * @var bool
  84.      *
  85.      * @ORM\Column(name="enabled", type="boolean", options={"default": 1}, nullable=false)
  86.      */
  87.     private $enabled true;
  88.     /**
  89.      * @var DateTime
  90.      *
  91.      * @ORM\Column(name="created", type="datetime", nullable=false)
  92.      * @Gedmo\Timestampable(on="create")
  93.      */
  94.     private $created;
  95.     /**
  96.      * @var DateTime
  97.      *
  98.      * @ORM\Column(name="updated", type="datetime", nullable=false)
  99.      * @Gedmo\Timestampable(on="update")
  100.      */
  101.     private $updated;
  102.     /**
  103.      * Gets the id.
  104.      *
  105.      * @return int
  106.      */
  107.     public function getId(): int
  108.     {
  109.         return $this->id;
  110.     }
  111.     /**
  112.      * Sets the id.
  113.      *
  114.      * @param int $id
  115.      * @return $this
  116.      */
  117.     public function setId(int $id): self
  118.     {
  119.         $this->id $id;
  120.         return $this;
  121.     }
  122.     /**
  123.      * Gets the abbreviated name.
  124.      *
  125.      * @return string
  126.      */
  127.     public function getAbbr(): string
  128.     {
  129.         return $this->abbr;
  130.     }
  131.     /**
  132.      * Sets the abbreviated name.
  133.      *
  134.      * @param string $abbr
  135.      * @return $this
  136.      */
  137.     public function setAbbr(string $abbr): self
  138.     {
  139.         $this->abbr strtoupper($abbr);
  140.         return $this;
  141.     }
  142.     /**
  143.      * Gets the name.
  144.      *
  145.      * @return string
  146.      */
  147.     public function getName(): string
  148.     {
  149.         return $this->name;
  150.     }
  151.     /**
  152.      * Sets the name.
  153.      *
  154.      * @param string $name
  155.      * @return $this
  156.      */
  157.     public function setName(string $name): self
  158.     {
  159.         $this->name $name;
  160.         return $this;
  161.     }
  162.     /**
  163.      * Gets the endpoint.
  164.      *
  165.      * @return string
  166.      */
  167.     public function getEndpoint(): string
  168.     {
  169.         return $this->endpoint;
  170.     }
  171.     /**
  172.      * Sets the endpoint.
  173.      *
  174.      * @param string $endpoint
  175.      * @return $this
  176.      */
  177.     public function setEndpoint(string $endpoint): self
  178.     {
  179.         $this->endpoint $endpoint;
  180.         return $this;
  181.     }
  182.     /**
  183.      * Gets the protocol.
  184.      *
  185.      * @return string
  186.      */
  187.     public function getProtocol(): string
  188.     {
  189.         return $this->protocol;
  190.     }
  191.     /**
  192.      * Sets the protocol.
  193.      *
  194.      * @param string $protocol
  195.      * @return $this
  196.      */
  197.     public function setProtocol(string $protocol): self
  198.     {
  199.         $this->protocol $protocol;
  200.         return $this;
  201.     }
  202.     /**
  203.      * Gets the ad id.
  204.      *
  205.      * @return int
  206.      */
  207.     public function getAdId(): int
  208.     {
  209.         return $this->adId;
  210.     }
  211.     /**
  212.      * Sets the ad id.
  213.      *
  214.      * @param int $adId
  215.      * @return $this
  216.      */
  217.     public function setAdId(int $adId): self
  218.     {
  219.         $this->adId $adId;
  220.         return $this;
  221.     }
  222.     /**
  223.      * Get countries.
  224.      *
  225.      * @return array
  226.      */
  227.     public function getCountries(): array
  228.     {
  229.         return $this->countries;
  230.     }
  231.     /**
  232.      * Set countries.
  233.      *
  234.      * @param array $countries
  235.      * @return $this
  236.      */
  237.     public function setCountries(array $countries): self
  238.     {
  239.         $this->countries $countries;
  240.         return $this;
  241.     }
  242.     /**
  243.      * Get valid device types.
  244.      *
  245.      * @return array
  246.      */
  247.     public function getDeviceTypes(): array
  248.     {
  249.         return $this->deviceTypes;
  250.     }
  251.     /**
  252.      * Set valid device types.
  253.      *
  254.      * @param array $deviceTypes
  255.      * @return $this
  256.      */
  257.     public function setDeviceTypes(array $deviceTypes): self
  258.     {
  259.         $this->deviceTypes $deviceTypes;
  260.         return $this;
  261.     }
  262.     /**
  263.      * Gets the scan frequency.
  264.      *
  265.      * @return int
  266.      */
  267.     public function getScanFrequency(): int
  268.     {
  269.         return $this->scanFrequency;
  270.     }
  271.     /**
  272.      * Sets the scan frequency.
  273.      *
  274.      * @param int $scanFrequency
  275.      * @return $this
  276.      */
  277.     public function setScanFrequency(int $scanFrequency): self
  278.     {
  279.         if (!ScanFrequency::isValid($scanFrequency)) {
  280.             throw new InvalidArgumentException("The scan frequency {$scanFrequency} is not valid!");
  281.         }
  282.         $this->scanFrequency $scanFrequency;
  283.         return $this;
  284.     }
  285.     /**
  286.      * If project is enabled.
  287.      *
  288.      * @return bool
  289.      */
  290.     public function isEnabled(): bool
  291.     {
  292.         return $this->enabled;
  293.     }
  294.     /**
  295.      * Sets if project is enabled.
  296.      *
  297.      * @param bool $enabled
  298.      * @return $this
  299.      */
  300.     public function setEnabled(bool $enabled): self
  301.     {
  302.         $this->enabled $enabled;
  303.         return $this;
  304.     }
  305.     /**
  306.      * Gets the created date.
  307.      *
  308.      * @return DateTime
  309.      */
  310.     public function getCreated(): DateTime
  311.     {
  312.         return ($this->created ?? new DateTime());
  313.     }
  314.     /**
  315.      * Sets the created date.
  316.      *
  317.      * @param DateTime $created
  318.      * @return $this
  319.      */
  320.     public function setCreated(DateTime $created): self
  321.     {
  322.         $this->created $created;
  323.         return $this;
  324.     }
  325.     /**
  326.      * Gets the updated value.
  327.      *
  328.      * @return DateTime
  329.      */
  330.     public function getUpdated(): DateTime
  331.     {
  332.         return ($this->updated ?? new DateTime());
  333.     }
  334.     /**
  335.      * Sets the updated value.
  336.      *
  337.      * @param DateTime $updated
  338.      * @return $this
  339.      */
  340.     public function setUpdated(DateTime $updated): self
  341.     {
  342.         $this->updated $updated;
  343.         return $this;
  344.     }
  345. }