<?php
namespace App\Entity;
use App\Model\GeoEdge\ScanFrequency;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use InvalidArgumentException;
/**
* SSP Endpoint entity.
*
* @ORM\Table(
* name="ssp_endpoints",
* uniqueConstraints={
* @ORM\UniqueConstraint(name="uk_ssp_endpoint_abbr", columns={"abbr"}),
* @ORM\UniqueConstraint(name="uk_ssp_endpoint_name", columns={"name"}),
* @ORM\UniqueConstraint(name="uk_ssp_endpoint_endpoint", columns={"endpoint"}),
* @ORM\UniqueConstraint(name="uk_ssp_endpoint_ad_id", columns={"ad_id"})
* }
* )
* @ORM\Entity(repositoryClass="App\Repository\SspEndpointRepository")
*/
class SspEndpoint
{
/**
* @var int
*
* @ORM\Id()
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(name="id", type="integer", nullable=false)
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="abbr", type="string", length=8, nullable=false)
*/
private $abbr;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=64, nullable=false)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="endpoint", type="string", length=255, nullable=false)
*/
private $endpoint;
/**
* @var string
*
* @ORM\Column(name="protocol", type="string", length=16, nullable=false)
*/
private $protocol;
/**
* @var int
*
* @ORM\Column(name="ad_id", type="integer", nullable=false)
*/
private $adId;
/**
* @var array
*
* @ORM\Column(name="countries", type="simple_array", nullable=true)
*/
private $countries = [];
/**
* @var array
*
* @ORM\Column(name="device_types", type="simple_array", nullable=true)
*/
private $deviceTypes = [];
/**
* How many times a target should be scanned per day. (GeoEdge times_per_day)
*
* @var int
*
* @ORM\Column(name="scan_frequency", type="integer", nullable=false, options={"default": 48})
*/
private $scanFrequency = ScanFrequency::TIMES_PER_DAY_SSP;
/**
* @var bool
*
* @ORM\Column(name="enabled", type="boolean", options={"default": 1}, nullable=false)
*/
private $enabled = true;
/**
* @var DateTime
*
* @ORM\Column(name="created", type="datetime", nullable=false)
* @Gedmo\Timestampable(on="create")
*/
private $created;
/**
* @var DateTime
*
* @ORM\Column(name="updated", type="datetime", nullable=false)
* @Gedmo\Timestampable(on="update")
*/
private $updated;
/**
* Gets the id.
*
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* Sets the id.
*
* @param int $id
* @return $this
*/
public function setId(int $id): self
{
$this->id = $id;
return $this;
}
/**
* Gets the abbreviated name.
*
* @return string
*/
public function getAbbr(): string
{
return $this->abbr;
}
/**
* Sets the abbreviated name.
*
* @param string $abbr
* @return $this
*/
public function setAbbr(string $abbr): self
{
$this->abbr = strtoupper($abbr);
return $this;
}
/**
* Gets the name.
*
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* Sets the name.
*
* @param string $name
* @return $this
*/
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* Gets the endpoint.
*
* @return string
*/
public function getEndpoint(): string
{
return $this->endpoint;
}
/**
* Sets the endpoint.
*
* @param string $endpoint
* @return $this
*/
public function setEndpoint(string $endpoint): self
{
$this->endpoint = $endpoint;
return $this;
}
/**
* Gets the protocol.
*
* @return string
*/
public function getProtocol(): string
{
return $this->protocol;
}
/**
* Sets the protocol.
*
* @param string $protocol
* @return $this
*/
public function setProtocol(string $protocol): self
{
$this->protocol = $protocol;
return $this;
}
/**
* Gets the ad id.
*
* @return int
*/
public function getAdId(): int
{
return $this->adId;
}
/**
* Sets the ad id.
*
* @param int $adId
* @return $this
*/
public function setAdId(int $adId): self
{
$this->adId = $adId;
return $this;
}
/**
* Get countries.
*
* @return array
*/
public function getCountries(): array
{
return $this->countries;
}
/**
* Set countries.
*
* @param array $countries
* @return $this
*/
public function setCountries(array $countries): self
{
$this->countries = $countries;
return $this;
}
/**
* Get valid device types.
*
* @return array
*/
public function getDeviceTypes(): array
{
return $this->deviceTypes;
}
/**
* Set valid device types.
*
* @param array $deviceTypes
* @return $this
*/
public function setDeviceTypes(array $deviceTypes): self
{
$this->deviceTypes = $deviceTypes;
return $this;
}
/**
* Gets the scan frequency.
*
* @return int
*/
public function getScanFrequency(): int
{
return $this->scanFrequency;
}
/**
* Sets the scan frequency.
*
* @param int $scanFrequency
* @return $this
*/
public function setScanFrequency(int $scanFrequency): self
{
if (!ScanFrequency::isValid($scanFrequency)) {
throw new InvalidArgumentException("The scan frequency {$scanFrequency} is not valid!");
}
$this->scanFrequency = $scanFrequency;
return $this;
}
/**
* If project is enabled.
*
* @return bool
*/
public function isEnabled(): bool
{
return $this->enabled;
}
/**
* Sets if project is enabled.
*
* @param bool $enabled
* @return $this
*/
public function setEnabled(bool $enabled): self
{
$this->enabled = $enabled;
return $this;
}
/**
* Gets the created date.
*
* @return DateTime
*/
public function getCreated(): DateTime
{
return ($this->created ?? new DateTime());
}
/**
* Sets the created date.
*
* @param DateTime $created
* @return $this
*/
public function setCreated(DateTime $created): self
{
$this->created = $created;
return $this;
}
/**
* Gets the updated value.
*
* @return DateTime
*/
public function getUpdated(): DateTime
{
return ($this->updated ?? new DateTime());
}
/**
* Sets the updated value.
*
* @param DateTime $updated
* @return $this
*/
public function setUpdated(DateTime $updated): self
{
$this->updated = $updated;
return $this;
}
}