src/Entity/Answer.php line 11
<?phpnamespace App\Entity;use App\Repository\AnswerRepository;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Gedmo\Timestampable\Traits\TimestampableEntity;#[ORM\Entity(AnswerRepository::class)]class Answer{use TimestampableEntity;#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id;#[ORM\Column(type: Types::TEXT)]private ?string $answer;#[ORM\ManyToOne(inversedBy: 'answers')]#[ORM\JoinColumn(nullable: false)]private ?Question $question;#[ORM\ManyToOne(inversedBy: 'answers')]#[ORM\JoinColumn(nullable: false)]private ?User $answeredBy;#[ORM\Column]private int $votes = 0;public function __toString(): string{return $this->getId();}public function getId(): ?int{return $this->id;}public function getAnswer(): ?string{return $this->answer;}public function setAnswer(string $answer): self{$this->answer = $answer;return $this;}public function getQuestion(): ?Question{return $this->question;}public function setQuestion(?Question $question): self{$this->question = $question;return $this;}public function getAnsweredBy(): ?User{return $this->answeredBy;}public function setAnsweredBy(?User $answeredBy): self{$this->answeredBy = $answeredBy;return $this;}public function getVotes(): int{return $this->votes;}public function getVotesString(): string{$prefix = $this->getVotes() >= 0 ? '+' : '-';return sprintf('%s %d', $prefix, abs($this->getVotes()));}public function setVotes(int $votes): self{$this->votes = $votes;return $this;}}