vendor/croisiland/common-bundle/src/Entity/Ship/Fuel.php line 19

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Croisiland\CommonBundle\Entity\Ship;
  4. use Crea\ToolsBundle\Entity\LifecycleUserIdentifierTrait;
  5. use Croisiland\CommonBundle\Annotation\Ship\FuelFormValidator;
  6. use Croisiland\CommonBundle\Repository\Ship\FuelRepository;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. /**
  11. * @ORM\Entity(repositoryClass=FuelRepository::class)
  12. *
  13. * @FuelFormValidator(groups={"fuel_form_validator"})
  14. */
  15. class Fuel
  16. {
  17. use LifecycleUserIdentifierTrait;
  18. /**
  19. * @ORM\Id
  20. *
  21. * @ORM\GeneratedValue
  22. *
  23. * @ORM\Column(type="integer")
  24. */
  25. private ?int $id;
  26. /**
  27. * @ORM\Column(type="string", length=255, nullable=false)
  28. */
  29. private ?string $name = null;
  30. /**
  31. * @ORM\Column(type="string", length=255, nullable=true)
  32. */
  33. private ?string $fullName = null;
  34. /**
  35. * @var Collection<int, Ship>
  36. *
  37. * @ORM\OneToMany(targetEntity=Ship::class, mappedBy="fuel")
  38. */
  39. private Collection $ships;
  40. public function __construct()
  41. {
  42. $this->ships = new ArrayCollection();
  43. }
  44. public function getId(): ?int
  45. {
  46. return $this->id;
  47. }
  48. public function getName(): ?string
  49. {
  50. return $this->name;
  51. }
  52. public function setName(?string $name): self
  53. {
  54. $this->name = $name;
  55. return $this;
  56. }
  57. public function getFullName(): ?string
  58. {
  59. return $this->fullName;
  60. }
  61. public function setFullName(?string $fullName): self
  62. {
  63. $this->fullName = $fullName;
  64. return $this;
  65. }
  66. /**
  67. * @return Collection<int, Ship>
  68. */
  69. public function getShips(): Collection
  70. {
  71. return $this->ships;
  72. }
  73. public function addShip(Ship $ship): self
  74. {
  75. if (!$this->ships->contains($ship)) {
  76. $this->ships[] = $ship;
  77. $ship->setFuel($this);
  78. }
  79. return $this;
  80. }
  81. public function removeShip(Ship $ship): self
  82. {
  83. if ($this->ships->removeElement($ship)) {
  84. // set the owning side to null (unless already changed)
  85. if ($ship->getFuel() === $this) {
  86. $ship->setFuel(null);
  87. }
  88. }
  89. return $this;
  90. }
  91. }