src/Entity/Domain.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use AllowDynamicProperties;
  4. use App\Attribute\Searchable;
  5. use App\Repository\DomainRepository;
  6. use App\Traits\DateTimeTrait;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Overblog\GraphQLBundle\Annotation\Field;
  11. #[AllowDynamicProperties]
  12. #[ORM\Entity(repositoryClassDomainRepository::class)]
  13. #[ORM\HasLifecycleCallbacks]
  14. class Domain extends BasicEntity
  15. {
  16.     use DateTimeTrait;
  17.     #[ORM\Id]
  18.     #[ORM\GeneratedValue]
  19.     #[ORM\Column(type"integer")]
  20.     #[Field(name"id"type"int")]
  21.     private $id;
  22.     #[ORM\Column(type"string"length255)]
  23.     #[Field(name"url"type"string")]
  24.     #[Searchable(name'url')]
  25.     private $url;
  26.     #[ORM\ManyToOne(targetEntityOrganisation::class, inversedBy"domains")]
  27.     #[ORM\JoinColumn(nullablefalse)]
  28.     private $organisation;
  29.     #[ORM\Column(type"boolean")]
  30.     #[Field(name"is_enabled"type"boolean")]
  31.     private $isEnabled;
  32.     #[ORM\OneToMany(mappedBy"domain"targetEntityExposedSubDomain::class, cascade: ["remove"])]
  33.     private $exposedSubDomains;
  34.     #[ORM\OneToMany(mappedBy"domain"targetEntityVulnerability::class, cascade: ["remove"])]
  35.     private $vulnerabilities;
  36.     #[ORM\OneToMany(mappedBy"domain"targetEntityDarkOwl::class, cascade: ["remove"])]
  37.     private $darkOwls;
  38.     #[ORM\OneToMany(mappedBy"domain"targetEntityDomainScore::class, cascade: ["remove"])]
  39.     private $domainScores;
  40.     #[ORM\OneToMany(mappedBy'domain'targetEntityRecommendation::class)]
  41.     private Collection $recommendations;
  42.     #[ORM\OneToMany(mappedBy'domain'targetEntityLeakedPassword::class)]
  43.     private Collection $leakedPasswords;
  44.     #[ORM\OneToMany(mappedBy'domain'targetEntityScore::class)]
  45.     private Collection $scores;
  46.     #[ORM\OneToMany(mappedBy'domain'targetEntityExposedIp::class)]
  47.     private Collection $exposedIps;
  48.     #[ORM\ManyToMany(targetEntityGenericRecommendation::class, inversedBy'domains')]
  49.     private Collection $implementedGenericRecommendations;
  50.     #[ORM\OneToMany(mappedBy'domaine'targetEntityNotification::class)]
  51.     private Collection $notifications;
  52.     #[ORM\OneToMany(mappedBy'domain'targetEntityRansomware::class)]
  53.     private Collection $ransomwares;
  54.     public function __construct()
  55.     {
  56.         $this->exposedSubDomains = new ArrayCollection();
  57.         $this->vulnerabilities = new ArrayCollection();
  58.         $this->darkOwls = new ArrayCollection();
  59.         $this->domainScores = new ArrayCollection();
  60.         $this->recommendations = new ArrayCollection();
  61.         $this->leakedPasswords = new ArrayCollection();
  62.         $this->scores = new ArrayCollection();
  63.         $this->exposedIps = new ArrayCollection();
  64.         $this->implementedGenericRecommendations = new ArrayCollection();
  65.         $this->notifications = new ArrayCollection();
  66.     }
  67.     public function getId(): ?int
  68.     {
  69.         return $this->id;
  70.     }
  71.     public function getUrl(): ?string
  72.     {
  73.         return $this->url;
  74.     }
  75.     public function setUrl(string $url): self
  76.     {
  77.         $this->url $url;
  78.         return $this;
  79.     }
  80.     public function getOrganisation(): ?Organisation
  81.     {
  82.         return $this->organisation;
  83.     }
  84.     public function setOrganisation(?Organisation $organisation): self
  85.     {
  86.         $this->organisation $organisation;
  87.         return $this;
  88.     }
  89.     public function getIsEnabled(): ?bool
  90.     {
  91.         return $this->isEnabled;
  92.     }
  93.     public function setIsEnabled(bool $isEnabled): self
  94.     {
  95.         $this->isEnabled $isEnabled;
  96.         return $this;
  97.     }
  98.     /**
  99.      * @return Collection|ExposedSubDomain[]
  100.      */
  101.     public function getExposedSubDomains(): Collection
  102.     {
  103.         return $this->exposedSubDomains->filter(function($exposedSubdomain) {
  104.             return !$exposedSubdomain->getIsDeleted();
  105.         });
  106.     }
  107.     // Optionally add a method for getting all subdomains, including deleted ones
  108.     public function getAllExposedSubdomains(): Collection
  109.     {
  110.         return $this->exposedSubDomains;
  111.     }
  112.     public function addExposedSubDomain(ExposedSubDomain $exposedSubDomain): self
  113.     {
  114.         if (!$this->exposedSubDomains->contains($exposedSubDomain)) {
  115.             $this->exposedSubDomains[] = $exposedSubDomain;
  116.             $exposedSubDomain->setDomain($this);
  117.         }
  118.         return $this;
  119.     }
  120.     public function removeExposedSubDomain(ExposedSubDomain $exposedSubDomain): self
  121.     {
  122.         if ($this->exposedSubDomains->removeElement($exposedSubDomain)) {
  123.             // set the owning side to null (unless already changed)
  124.             if ($exposedSubDomain->getDomain() === $this) {
  125.                 $exposedSubDomain->setDomain(null);
  126.             }
  127.         }
  128.         return $this;
  129.     }
  130.     /**
  131.      * @return Collection|Vulnerability[]
  132.      */
  133.     public function getVulnerabilities(): Collection
  134.     {
  135.         return $this->vulnerabilities;
  136.     }
  137.     public function addVulnerability(Vulnerability $vulnerability): self
  138.     {
  139.         if (!$this->vulnerabilities->contains($vulnerability)) {
  140.             $this->vulnerabilities[] = $vulnerability;
  141.             $vulnerability->setDomain($this);
  142.         }
  143.         return $this;
  144.     }
  145.     public function removeVulnerability(Vulnerability $vulnerability): self
  146.     {
  147.         if ($this->vulnerabilities->removeElement($vulnerability)) {
  148.             // set the owning side to null (unless already changed)
  149.             if ($vulnerability->getDomain() === $this) {
  150.                 $vulnerability->setDomain(null);
  151.             }
  152.         }
  153.         return $this;
  154.     }
  155.     /**
  156.      * @return Collection<int, DarkOwl>
  157.      */
  158.     public function getDarkOwls(): Collection
  159.     {
  160.         return $this->darkOwls;
  161.     }
  162.     public function addDarkOwl(DarkOwl $darkOwl): self
  163.     {
  164.         if (!$this->darkOwls->contains($darkOwl)) {
  165.             $this->darkOwls[] = $darkOwl;
  166.             $darkOwl->setDomain($this);
  167.         }
  168.         return $this;
  169.     }
  170.     public function removeDarkOwl(DarkOwl $darkOwl): self
  171.     {
  172.         if ($this->darkOwls->removeElement($darkOwl)) {
  173.             // set the owning side to null (unless already changed)
  174.             if ($darkOwl->getDomain() === $this) {
  175.                 $darkOwl->setDomain(null);
  176.             }
  177.         }
  178.         return $this;
  179.     }
  180.     /**
  181.      * @return Collection<int, DomainScore>
  182.      */
  183.     public function getDomainScores(): Collection
  184.     {
  185.         return $this->domainScores;
  186.     }
  187.     public function addDomainScore(DomainScore $domainScore): self
  188.     {
  189.         if (!$this->domainScores->contains($domainScore)) {
  190.             $this->domainScores[] = $domainScore;
  191.             $domainScore->setDomain($this);
  192.         }
  193.         return $this;
  194.     }
  195.     public function removeDomainScore(DomainScore $domainScore): self
  196.     {
  197.         if ($this->domainScores->removeElement($domainScore)) {
  198.             // set the owning side to null (unless already changed)
  199.             if ($domainScore->getDomain() === $this) {
  200.                 $domainScore->setDomain(null);
  201.             }
  202.         }
  203.         return $this;
  204.     }
  205.     public function getLastScore(): ?DomainScore
  206.     {
  207.         $score null;
  208.         foreach ($this->getDomainScores() as $key => $value) {
  209.             $score $value;
  210.         }
  211.         return $score;
  212.     }
  213.     /**
  214.      * @return Collection<int, Recommendation>
  215.      */
  216.     public function getRecommendations(): Collection
  217.     {
  218.         return $this->recommendations;
  219.     }
  220.     public function addRecommendation(Recommendation $recommendation): static
  221.     {
  222.         if (!$this->recommendations->contains($recommendation)) {
  223.             $this->recommendations->add($recommendation);
  224.             $recommendation->setDomain($this);
  225.         }
  226.         return $this;
  227.     }
  228.     public function removeRecommendation(Recommendation $recommendation): static
  229.     {
  230.         if ($this->recommendations->removeElement($recommendation)) {
  231.             // set the owning side to null (unless already changed)
  232.             if ($recommendation->getDomain() === $this) {
  233.                 $recommendation->setDomain(null);
  234.             }
  235.         }
  236.         return $this;
  237.     }
  238.     /**
  239.      * @return Collection<int, LeakedPassword>
  240.      */
  241.     public function getLeakedPasswords(): Collection
  242.     {
  243.         return $this->leakedPasswords;
  244.     }
  245.     public function addLeakedPassword(LeakedPassword $leakedPassword): static
  246.     {
  247.         if (!$this->leakedPasswords->contains($leakedPassword)) {
  248.             $this->leakedPasswords->add($leakedPassword);
  249.             $leakedPassword->setDomain($this);
  250.         }
  251.         return $this;
  252.     }
  253.     public function removeLeakedPassword(LeakedPassword $leakedPassword): static
  254.     {
  255.         if ($this->leakedPasswords->removeElement($leakedPassword)) {
  256.             // set the owning side to null (unless already changed)
  257.             if ($leakedPassword->getDomain() === $this) {
  258.                 $leakedPassword->setDomain(null);
  259.             }
  260.         }
  261.         return $this;
  262.     }
  263.     /**
  264.      * @return Collection<int, Score>
  265.      */
  266.     public function getScores(): Collection
  267.     {
  268.         return $this->scores;
  269.     }
  270.     public function addScore(Score $score): static
  271.     {
  272.         if (!$this->scores->contains($score)) {
  273.             $this->scores->add($score);
  274.             $score->setDomain($this);
  275.         }
  276.         return $this;
  277.     }
  278.     public function removeScore(Score $score): static
  279.     {
  280.         if ($this->scores->removeElement($score)) {
  281.             // set the owning side to null (unless already changed)
  282.             if ($score->getDomain() === $this) {
  283.                 $score->setDomain(null);
  284.             }
  285.         }
  286.         return $this;
  287.     }
  288.     /**
  289.      * @return Collection<int, ExposedIp>
  290.      */
  291.     public function getExposedIps(): Collection
  292.     {
  293.         return $this->exposedIps;
  294.     }
  295.     public function addExposedIp(ExposedIp $exposedIp): static
  296.     {
  297.         if (!$this->exposedIps->contains($exposedIp)) {
  298.             $this->exposedIps->add($exposedIp);
  299.             $exposedIp->setDomain($this);
  300.         }
  301.         return $this;
  302.     }
  303.     public function removeExposedIp(ExposedIp $exposedIp): static
  304.     {
  305.         if ($this->exposedIps->removeElement($exposedIp)) {
  306.             // set the owning side to null (unless already changed)
  307.             if ($exposedIp->getDomain() === $this) {
  308.                 $exposedIp->setDomain(null);
  309.             }
  310.         }
  311.         return $this;
  312.     }
  313.     /**
  314.      * @return Collection<int, GenericRecommendation>
  315.      */
  316.     public function getImplementedGenericRecommendations(): Collection
  317.     {
  318.         return $this->implementedGenericRecommendations;
  319.     }
  320.     public function addImplementedGenericRecommendation(GenericRecommendation $implementedGenericRecommendation): static
  321.     {
  322.         if (!$this->implementedGenericRecommendations->contains($implementedGenericRecommendation)) {
  323.             $this->implementedGenericRecommendations->add($implementedGenericRecommendation);
  324.         }
  325.         return $this;
  326.     }
  327.     public function removeImplementedGenericRecommendation(GenericRecommendation $implementedGenericRecommendation): static
  328.     {
  329.         $this->implementedGenericRecommendations->removeElement($implementedGenericRecommendation);
  330.         return $this;
  331.     }
  332.     /**
  333.      * @return Collection<int, Notification>
  334.      */
  335.     public function getNotifications(): Collection
  336.     {
  337.         return $this->notifications;
  338.     }
  339.     public function addNotification(Notification $notification): static
  340.     {
  341.         if (!$this->notifications->contains($notification)) {
  342.             $this->notifications->add($notification);
  343.             $notification->setDomain($this);
  344.         }
  345.         return $this;
  346.     }
  347.     public function removeNotification(Notification $notification): static
  348.     {
  349.         if ($this->notifications->removeElement($notification)) {
  350.             // set the owning side to null (unless already changed)
  351.             if ($notification->getDomain() === $this) {
  352.                 $notification->setDomain(null);
  353.             }
  354.         }
  355.         return $this;
  356.     }
  357. }