src/Entity/ExposedIp.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Attribute\Searchable;
  4. use App\Repository\ExposedIpRepository;
  5. use App\Traits\DateTimeTrait;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Overblog\GraphQLBundle\Annotation\Field;
  10. use DateTimeImmutable;
  11. #[ORM\Entity(repositoryClassExposedIpRepository::class)]
  12. #[ORM\HasLifecycleCallbacks]
  13. class ExposedIp extends BasicEntity
  14. {
  15.     use DateTimeTrait;
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column(type"integer")]
  19.     #[Field(name"id"type"int")]
  20.     private $id;
  21.     #[ORM\Column(type"string"length15)]
  22.     #[Field(name"ip"type"string")]
  23.     #[Searchable(name'ip')]
  24.     private $ip;
  25.     #[ORM\ManyToMany(targetEntityPort::class, inversedBy:'exposedIps'cascade: ["persist""remove"])]
  26.     private $ports;
  27.     #[ORM\ManyToOne(targetEntityOrganisation::class, inversedBy"exposedIps")]
  28.     #[ORM\JoinColumn(nullablefalse)]
  29.     #[Field(name"organisation")]
  30.     private $organisation;
  31.     #[ORM\Column(type"boolean"nullabletrue)]
  32.     #[Field(name"is_exposed"type"boolean")]
  33.     private $isExposed;
  34.     #[ORM\Column(type"boolean"nullabletrue)]
  35.     #[Field(name"is_normal"type"boolean")]
  36.     private $isNormal;
  37.     #[ORM\Column(type"boolean"nullabletrue)]
  38.     #[Field(name"is_cdn"type"boolean")]
  39.     private $isCdn;
  40.     #[ORM\OneToMany(mappedBy"exposedIp"targetEntityExposedSubDomain::class, cascade: ["persist""remove"])]
  41.     private $exposedSubDomains;
  42.     #[ORM\OneToMany(mappedBy"exposedIp"targetEntityOpenPort::class, cascade: ["persist""remove"])]
  43.     private $openPorts;
  44.     #[ORM\ManyToOne(inversedBy'exposedIps')]
  45.     private ?Domain $domain null;
  46.     #[ORM\Column(type"boolean"options: ['default' => true])]
  47.     #[Field(name"is_active"type"boolean")]
  48.     private $isActive;
  49.     #[ORM\Column(type'datetime_immutable'nullabletrue)]
  50.     #[Field(name"last_seen"type"string")]
  51.     private $lastSeen;
  52.     #[ORM\ManyToOne(targetEntityStatus::class, inversedBy'exposedIps')]
  53.     #[ORM\JoinColumn(nullabletrueoptions: ['default' => 1])]
  54.     #[Field(name"status")]
  55.     private $status;
  56.     public function __construct()
  57.     {
  58.         $this->ports = new ArrayCollection();
  59.     }
  60.     public function getId(): ?int
  61.     {
  62.         return $this->id;
  63.     }
  64.     public function getIp(): ?string
  65.     {
  66.         return $this->ip;
  67.     }
  68.     public function setIp(string $ip): self
  69.     {
  70.         $this->ip $ip;
  71.         return $this;
  72.     }
  73.     /**
  74.      * @return Collection|Port[]
  75.      */
  76.     public function getPorts(): Collection
  77.     {
  78.         return $this->ports;
  79.     }
  80.     public function addPort(Port $port): self
  81.     {
  82.         if (!$this->ports->contains($port)) {
  83.             $this->ports[] = $port;
  84.         }
  85.         return $this;
  86.     }
  87.     public function removePort(Port $port): self
  88.     {
  89.         $this->ports->removeElement($port);
  90.         return $this;
  91.     }
  92.     public function getOrganisation(): ?Organisation
  93.     {
  94.         return $this->organisation;
  95.     }
  96.     public function setOrganisation(?Organisation $organisation): self
  97.     {
  98.         $this->organisation $organisation;
  99.         return $this;
  100.     }
  101.     public function getIsExposed(): ?bool
  102.     {
  103.         return $this->isExposed;
  104.     }
  105.     public function setIsExposed(?bool $isExposed): self
  106.     {
  107.         $this->isExposed $isExposed;
  108.         return $this;
  109.     }
  110.     public function getIsNormal(): ?bool
  111.     {
  112.         return $this->isNormal;
  113.     }
  114.     public function setIsNormal(?bool $isNormal): self
  115.     {
  116.         $this->isNormal $isNormal;
  117.         return $this;
  118.     }
  119.     public function getIsCdn(): ?bool
  120.     {
  121.         return $this->isCdn;
  122.     }
  123.     public function setIsCdn(?bool $isCdn): self
  124.     {
  125.         $this->isCdn $isCdn;
  126.         return $this;
  127.     }
  128.     public function getIsActive(): ?bool
  129.     {
  130.         return $this->isActive;
  131.     }
  132.     public function setIsActive(?bool $isActive): self
  133.     {
  134.         $this->isActive $isActive;
  135.         return $this;
  136.     }
  137.     public function getLastSeen(): ?DateTimeImmutable
  138.     {
  139.         return $this->lastSeen;
  140.     }
  141.     public function setLastSeen(?DateTimeImmutable $lastSeen): self
  142.     {
  143.         $this->lastSeen $lastSeen;
  144.         return $this;
  145.     }
  146.     public function getExposedSubDomains(): Collection
  147.     {
  148.         return $this->exposedSubDomains->filter(function($exposedSubdomain) {
  149.             return !$exposedSubdomain->getIsDeleted();
  150.         });
  151.     }
  152.     // Optionally add a method for getting all subdomains, including deleted ones
  153.     public function getAllExposedSubdomains(): Collection
  154.     {
  155.         return $this->exposedSubDomains;
  156.     }
  157.     public function setExposedSubDomains(?Collection $exposedSubDomains): self
  158.     {
  159.         // unset the owning side of the relation if necessary
  160.         if ($exposedSubDomains === null && $this->exposedSubDomains !== null) {
  161.             $this->exposedSubDomains->setExposedIp(null);
  162.         }
  163.         // set the owning side of the relation if necessary
  164.         if ($exposedSubDomains !== null && $exposedSubDomains->getExposedIp() !== $this) {
  165.             $exposedSubDomains->setExposedIp($this);
  166.         }
  167.         $this->exposedSubDomains $exposedSubDomains;
  168.         return $this;
  169.     }
  170.     // Optionally add a method for getting all subdomains, including deleted ones
  171.     public function getOpenPorts(): Collection
  172.     {
  173.         return $this->openPorts;
  174.     }
  175.     public function setOpenPorts(?Collection $openPorts): self
  176.     {
  177.         $this->openPorts $openPorts;
  178.         return $this;
  179.     }
  180.     public function getDomain(): ?Domain
  181.     {
  182.         return $this->domain;
  183.     }
  184.     public function setDomain(?Domain $domain): static
  185.     {
  186.         $this->domain $domain;
  187.         return $this;
  188.     }
  189.     public function getStatus(): ?Status
  190.     {
  191.         return $this->status;
  192.     }
  193.     public function setStatus(?Status $status): self
  194.     {
  195.         $this->status $status;
  196.         return $this;
  197.     }
  198. }