poll = new ArrayCollection(); $this->stackOfVotes = new ArrayCollection(); $this->votes = new ArrayCollection(); $this->setDateTime( new \DateTime() ); } public function getId(): ?int { return $this->id; } public function getName(): ?string { return $this->name; } public function setName( $name ): self { if ( is_a( $name, 'DateTime' ) ) { $this->setDateTime( $name ); $name = $name->format( 'D Y-m-d' ); } $this->name = $name; return $this; } public function getDateTime(): ?DateTimeInterface { return $this->dateTime; } public function setDateTime( ?DateTimeInterface $dateTime ): self { $this->dateTime = $dateTime; return $this; } /** * @return Collection|Poll[] */ public function getPoll(): Collection { return $this->poll; } public function setPoll( Poll $poll ): self { $this->poll = [ $poll ]; return $this; } public function addPoll( Poll $poll ): self { if ( ! $this->poll->contains( $poll ) ) { $this->poll[] = $poll; $poll->setChoices( $this ); } return $this; } public function removePoll( Poll $poll ): self { if ( $this->poll->contains( $poll ) ) { $this->poll->removeElement( $poll ); // set the owning side to null (unless already changed) if ( $poll->getChoices() === $this ) { $poll->setChoices( null ); } } return $this; } /** * @return Collection|Choice[] */ public function getStackOfVotes(): Collection { return $this->stackOfVotes; } public function addVote( Choice $vote ): self { if ( ! $this->stackOfVotes->contains( $vote ) ) { $this->stackOfVotes[] = $vote; $vote->setChoice( $this ); } return $this; } public function removeVote( Choice $vote ): self { if ( $this->stackOfVotes->contains( $vote ) ) { $this->stackOfVotes->removeElement( $vote ); // set the owning side to null (unless already changed) if ( $vote->getChoice() === $this ) { $vote->setChoice( null ); } } return $this; } public function addStackOfVote( StackOfVotes $stackOfVote ): self { if ( ! $this->stackOfVotes->contains( $stackOfVote ) ) { $this->stackOfVotes[] = $stackOfVote; $stackOfVote->setChoice( $this ); } return $this; } public function removeStackOfVote( StackOfVotes $stackOfVote ): self { if ( $this->stackOfVotes->contains( $stackOfVote ) ) { $this->stackOfVotes->removeElement( $stackOfVote ); // set the owning side to null (unless already changed) if ( $stackOfVote->getChoice() === $this ) { $stackOfVote->setChoice( null ); } } return $this; } /** * @return Collection|Vote[] */ public function getVotes(): Collection { return $this->votes; } }