src/Entity/TelegramUser.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TelegramUserRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=TelegramUserRepository::class)
  9.  */
  10. class TelegramUser
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=255, nullable=true)
  20.      */
  21.     private $username;
  22.     /**
  23.      * @ORM\Column(type="string")
  24.      */
  25.     private $userId;
  26.     /**
  27.      * @ORM\Column(type="string", length=255, nullable=true)
  28.      */
  29.     private $name;
  30.     /**
  31.      * @ORM\Column(type="text", nullable=true)
  32.      */
  33.     private $waitBotCommandParam;
  34.     /**
  35.      * @ORM\ManyToMany(targetEntity=TelegramChat::class, inversedBy="administrators")
  36.      */
  37.     private $administratesChats;
  38.     public function __construct()
  39.     {
  40.         $this->administratesChats = new ArrayCollection();
  41.     }
  42.     public function getId(): ?int
  43.     {
  44.         return $this->id;
  45.     }
  46.     public function getUsername(): ?string
  47.     {
  48.         return $this->username;
  49.     }
  50.     public function setUsername(?string $username): self
  51.     {
  52.         $this->username $username;
  53.         return $this;
  54.     }
  55.     public function getUserId(): ?string
  56.     {
  57.         return $this->userId;
  58.     }
  59.     public function setUserId(string $userId): self
  60.     {
  61.         $this->userId $userId;
  62.         return $this;
  63.     }
  64.     public function getName(): ?string
  65.     {
  66.         return $this->name;
  67.     }
  68.     public function setName(?string $name): self
  69.     {
  70.         $this->name $name;
  71.         return $this;
  72.     }
  73.     public function getWaitBotCommandParam(): ?array
  74.     {
  75.         if (!$this->waitBotCommandParam) {
  76.             return $this->waitBotCommandParam;
  77.         }
  78.         return json_decode($this->waitBotCommandParamtrue);
  79.     }
  80.     public function setWaitBotCommandParam(?array $waitBotCommandParam): self
  81.     {
  82.         if (!$waitBotCommandParam) {
  83.             $this->waitBotCommandParam $waitBotCommandParam;
  84.             return $this;
  85.         }
  86.         $this->waitBotCommandParam json_encode($waitBotCommandParam,
  87.             JSON_UNESCAPED_UNICODE JSON_UNESCAPED_SLASHES);
  88.         return $this;
  89.     }
  90.     public function changeWaitBotCommandParam(array $params)
  91.     {
  92.         $data $this->getWaitBotCommandParam();
  93.         if (!$data) {
  94.             $data = [];
  95.         }
  96.         $data array_merge($data$params);
  97.         $this->setWaitBotCommandParam($data);
  98.     }
  99.     public function clearWaitBotCommandParam()
  100.     {
  101.         $this->setWaitBotCommandParam(null);
  102.     }
  103.     /**
  104.      * @return Collection<int, TelegramChat>
  105.      */
  106.     public function getAdministratesChats(): Collection
  107.     {
  108.         return $this->administratesChats;
  109.     }
  110.     public function addAdministratesChat(TelegramChat $administratesChat): self
  111.     {
  112.         if (!$this->administratesChats->contains($administratesChat)) {
  113.             $this->administratesChats[] = $administratesChat;
  114.         }
  115.         return $this;
  116.     }
  117.     public function removeAdministratesChat(TelegramChat $administratesChat): self
  118.     {
  119.         $this->administratesChats->removeElement($administratesChat);
  120.         return $this;
  121.     }
  122. }