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