src/Entity/Messengers.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use App\Validator\Constraints\TelegramUsernameNotValid;
  5. use Symfony\Component\Serializer\Annotation\Groups;
  6. #[ORM\Embeddable]
  7. final class Messengers
  8. {
  9.     #[ORM\Column(name'messengers_telegram'type'boolean'nullabletrue)]
  10.     protected ?bool $telegram;
  11.     #[ORM\Column(name'messengers_whatsapp'type'integer'nullabletrue)]
  12.     protected ?bool $whatsApp;
  13.     #[ORM\Column(name'messengers_telegram_username'type'string'length32nullabletrue)]
  14.     #[TelegramUsernameNotValid]
  15.     #[Groups(['preview''listing'])]
  16.     protected ?string $telegramUsername null;
  17.     public function __construct(?bool $telegram, ?bool $whatsApp, ?string $telegramUsername)
  18.     {
  19.         $this->telegram $telegram;
  20.         $this->whatsApp $whatsApp;
  21.         $this->telegramUsername $telegramUsername;
  22.     }
  23.     #[Groups(['preview''listing'])]
  24.     public function hasTelegram(): ?bool
  25.     {
  26.         return $this->telegram;
  27.     }
  28.     #[Groups(['preview''listing'])]
  29.     public function hasWhatsApp(): ?bool
  30.     {
  31.         return $this->whatsApp;
  32.     }
  33.     public function getTelegramUsername(): ?string
  34.     {
  35.         return $this->telegramUsername;
  36.     }
  37. }