Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 24 |
|
0.00% |
0 / 18 |
CRAP | |
0.00% |
0 / 1 |
TelegramLink | |
0.00% |
0 / 24 |
|
0.00% |
0 / 18 |
506 | |
0.00% |
0 / 1 |
getId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
setId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getPin | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setPin | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getPinExpiresAt | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setPinExpiresAt | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getUser | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setUser | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getTelegramChatId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setTelegramChatId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getTelegramUserId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setTelegramUserId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getTelegramChatState | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
setTelegramChatState | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
getCreatedAt | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setCreatedAt | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getLinkedAt | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setLinkedAt | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Olz\Entity; |
4 | |
5 | use Doctrine\ORM\Mapping as ORM; |
6 | use Olz\Entity\Users\User; |
7 | use Olz\Repository\TelegramLinkRepository; |
8 | |
9 | #[ORM\Table(name: 'telegram_links')] |
10 | #[ORM\Index(name: 'pin_index', columns: ['pin'])] |
11 | #[ORM\Index(name: 'user_id_index', columns: ['user_id'])] |
12 | #[ORM\Index(name: 'telegram_user_id_index', columns: ['telegram_user_id'])] |
13 | #[ORM\Index(name: 'telegram_chat_id_index', columns: ['telegram_chat_id'])] |
14 | #[ORM\Entity(repositoryClass: TelegramLinkRepository::class)] |
15 | class TelegramLink { |
16 | #[ORM\Column(type: 'string', nullable: true)] |
17 | private ?string $pin; |
18 | |
19 | #[ORM\Column(type: 'datetime', nullable: true)] |
20 | private ?\DateTime $pin_expires_at; |
21 | |
22 | #[ORM\ManyToOne(targetEntity: User::class)] |
23 | #[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', nullable: true)] |
24 | private ?User $user; |
25 | |
26 | #[ORM\Column(type: 'string', nullable: true)] |
27 | private ?string $telegram_chat_id; |
28 | |
29 | #[ORM\Column(type: 'string', nullable: true)] |
30 | private ?string $telegram_user_id; |
31 | |
32 | #[ORM\Column(type: 'text', nullable: false)] |
33 | private string $telegram_chat_state; |
34 | |
35 | #[ORM\Column(type: 'datetime', nullable: false, options: ['default' => 'CURRENT_TIMESTAMP'])] |
36 | private \DateTime $created_at; |
37 | |
38 | #[ORM\Column(type: 'datetime', nullable: true)] |
39 | private ?\DateTime $linked_at; |
40 | |
41 | #[ORM\Id] |
42 | #[ORM\Column(type: 'bigint', nullable: false)] |
43 | #[ORM\GeneratedValue] |
44 | private int|string $id; |
45 | |
46 | public function getId(): ?int { |
47 | return isset($this->id) ? intval($this->id) : null; |
48 | } |
49 | |
50 | public function setId(int $new_value): void { |
51 | $this->id = $new_value; |
52 | } |
53 | |
54 | public function getPin(): ?string { |
55 | return $this->pin; |
56 | } |
57 | |
58 | public function setPin(?string $new_value): void { |
59 | $this->pin = $new_value; |
60 | } |
61 | |
62 | public function getPinExpiresAt(): ?\DateTime { |
63 | return $this->pin_expires_at; |
64 | } |
65 | |
66 | public function setPinExpiresAt(?\DateTime $new_value): void { |
67 | $this->pin_expires_at = $new_value; |
68 | } |
69 | |
70 | public function getUser(): ?User { |
71 | return $this->user; |
72 | } |
73 | |
74 | public function setUser(?User $new_value): void { |
75 | $this->user = $new_value; |
76 | } |
77 | |
78 | public function getTelegramChatId(): ?string { |
79 | return $this->telegram_chat_id; |
80 | } |
81 | |
82 | public function setTelegramChatId(?string $new_value): void { |
83 | $this->telegram_chat_id = $new_value; |
84 | } |
85 | |
86 | public function getTelegramUserId(): ?string { |
87 | return $this->telegram_user_id; |
88 | } |
89 | |
90 | public function setTelegramUserId(?string $new_value): void { |
91 | $this->telegram_user_id = $new_value; |
92 | } |
93 | |
94 | /** @return array<string, mixed> */ |
95 | public function getTelegramChatState(): array { |
96 | if ($this->telegram_chat_state == null) { |
97 | return []; |
98 | } |
99 | $array = json_decode($this->telegram_chat_state, true); |
100 | return is_array($array) ? $array : []; |
101 | } |
102 | |
103 | /** @param array<string, mixed> $new_value */ |
104 | public function setTelegramChatState(array $new_value): void { |
105 | $enc_value = json_encode($new_value); |
106 | if (!$enc_value) { |
107 | return; |
108 | } |
109 | $this->telegram_chat_state = $enc_value; |
110 | } |
111 | |
112 | public function getCreatedAt(): \DateTime { |
113 | return $this->created_at; |
114 | } |
115 | |
116 | public function setCreatedAt(\DateTime $new_value): void { |
117 | $this->created_at = $new_value; |
118 | } |
119 | |
120 | public function getLinkedAt(): ?\DateTime { |
121 | return $this->linked_at; |
122 | } |
123 | |
124 | public function setLinkedAt(?\DateTime $new_value): void { |
125 | $this->linked_at = $new_value; |
126 | } |
127 | } |