src/Entity/Messengers.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Validator\Constraints\TelegramUsernameNotValid;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Serializer\Annotation\Groups;
  6. #[ORM\Embeddable]
  7. final class Messengers
  8. {
  9.     #[ORM\Column(name: 'messengers_telegram', type: 'boolean', nullable: true)]
  10.     protected ?bool $telegram;
  11.     #[ORM\Column(name: 'messengers_whatsapp', type: 'boolean', nullable: true)]
  12.     protected ?bool $whatsApp;
  13.     #[ORM\Column(name: 'messengers_max', type: 'boolean', nullable: true)]
  14.     protected ?bool $max;
  15.     #[ORM\Column(name: 'messengers_telegram_username', type: 'string', length: 32, nullable: true)]
  16.     #[TelegramUsernameNotValid]
  17.     #[Groups(['preview', 'listing'])]
  18.     protected ?string $telegramUsername = null;
  19.     #[ORM\Column(name: 'messengers_max_url', type: 'string', length: 255, nullable: true)]
  20.     #[Groups(['preview', 'listing'])]
  21.     protected ?string $maxUrl = null;
  22.     public function __construct(
  23.         ?bool $telegram,
  24.         ?bool $whatsApp,
  25.         ?string $telegramUsername,
  26.         ?bool $max = null,
  27.         ?string $maxUrl = null
  28.     )
  29.     {
  30.         $this->telegram = $telegram;
  31.         $this->whatsApp = $whatsApp;
  32.         $this->telegramUsername = $telegramUsername;
  33.         $this->max = $max;
  34.         $this->maxUrl = $maxUrl;
  35.     }
  36.     #[Groups(['preview', 'listing'])]
  37.     public function hasTelegram(): ?bool
  38.     {
  39.         return $this->telegram;
  40.     }
  41.     #[Groups(['preview', 'listing'])]
  42.     public function hasWhatsApp(): ?bool
  43.     {
  44.         return $this->whatsApp;
  45.     }
  46.     #[Groups(['preview', 'listing'])]
  47.     public function hasMax(): ?bool
  48.     {
  49.         return $this->max;
  50.     }
  51.     public function getTelegramUsername(): ?string
  52.     {
  53.         return $this->telegramUsername;
  54.     }
  55.     public function getMaxUrl(): ?string
  56.     {
  57.         return $this->maxUrl;
  58.     }
  59. }