<?php
declare(strict_types=1);
namespace Croisiland\CommonBundle\Entity\Ship;
use Crea\ToolsBundle\Entity\LifecycleUserIdentifierTrait;
use Croisiland\CommonBundle\Annotation\Ship\ShipEnvironmentalActionFormValidator;
use Croisiland\CommonBundle\Repository\Ship\ShipEnvironmentalActionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=ShipEnvironmentalActionRepository::class)
*
* @ShipEnvironmentalActionFormValidator(groups={"ship_environmental_action_form_validator"})
*/
class ShipEnvironmentalAction
{
use LifecycleUserIdentifierTrait;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id;
/**
* @ORM\Column(type="string", length=255)
*/
private ?string $name = null;
/**
* @var Collection<int, Ship>
*
* @ORM\ManyToMany(targetEntity=Ship::class, inversedBy="shipEnvironmentalActions")
*/
private Collection $ships;
public function __construct()
{
$this->ships = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return Collection<int, Ship>
*/
public function getShips(): Collection
{
return $this->ships;
}
public function addShip(Ship $ship): self
{
if (!$this->ships->contains($ship)) {
$this->ships[] = $ship;
$ship->addShipEnvironmentalAction($this);
}
return $this;
}
public function removeShip(Ship $ship): self
{
if ($this->ships->removeElement($ship)) {
$ship->removeShipEnvironmentalAction($this);
}
return $this;
}
}