<?php
namespace App\Entity;
use App\Repository\TelegramUserRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=TelegramUserRepository::class)
*/
class TelegramUser
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $username;
/**
* @ORM\Column(type="string")
*/
private $userId;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $name;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $waitBotCommandParam;
/**
* @ORM\ManyToMany(targetEntity=TelegramChat::class, inversedBy="administrators")
*/
private $administratesChats;
public function __construct()
{
$this->administratesChats = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getUsername(): ?string
{
return $this->username;
}
public function setUsername(?string $username): self
{
$this->username = $username;
return $this;
}
public function getUserId(): ?string
{
return $this->userId;
}
public function setUserId(string $userId): self
{
$this->userId = $userId;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getWaitBotCommandParam(): ?array
{
if (!$this->waitBotCommandParam) {
return $this->waitBotCommandParam;
}
return json_decode($this->waitBotCommandParam, true);
}
public function setWaitBotCommandParam(?array $waitBotCommandParam): self
{
if (!$waitBotCommandParam) {
$this->waitBotCommandParam = $waitBotCommandParam;
return $this;
}
$this->waitBotCommandParam = json_encode($waitBotCommandParam,
JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
return $this;
}
public function changeWaitBotCommandParam(array $params)
{
$data = $this->getWaitBotCommandParam();
if (!$data) {
$data = [];
}
$data = array_merge($data, $params);
$this->setWaitBotCommandParam($data);
}
public function clearWaitBotCommandParam()
{
$this->setWaitBotCommandParam(null);
}
/**
* @return Collection<int, TelegramChat>
*/
public function getAdministratesChats(): Collection
{
return $this->administratesChats;
}
public function addAdministratesChat(TelegramChat $administratesChat): self
{
if (!$this->administratesChats->contains($administratesChat)) {
$this->administratesChats[] = $administratesChat;
}
return $this;
}
public function removeAdministratesChat(TelegramChat $administratesChat): self
{
$this->administratesChats->removeElement($administratesChat);
return $this;
}
}