Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
94.44% |
17 / 18 |
|
94.44% |
17 / 18 |
CRAP | |
0.00% |
0 / 1 |
| AccessToken | |
94.44% |
17 / 18 |
|
94.44% |
17 / 18 |
19.06 | |
0.00% |
0 / 1 |
| getId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| setId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getUser | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setUser | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getPurpose | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setPurpose | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getToken | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setToken | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getCreatedAt | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setCreatedAt | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getExpiresAt | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setExpiresAt | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getOldToken | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setOldToken | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getRotatedAt | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setRotatedAt | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getVersion | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| testOnlyGetField | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 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\AccessTokenRepository; |
| 9 | |
| 10 | #[ORM\Table(name: 'access_tokens')] |
| 11 | #[ORM\Index(name: 'token_index', columns: ['token'])] |
| 12 | #[ORM\Index(name: 'user_id_index', columns: ['user_id'])] |
| 13 | #[ORM\Entity(repositoryClass: AccessTokenRepository::class)] |
| 14 | class AccessToken implements TestableInterface { |
| 15 | #[ORM\ManyToOne(targetEntity: User::class)] |
| 16 | #[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', nullable: true)] |
| 17 | private ?User $user; |
| 18 | |
| 19 | #[ORM\Column(type: 'string', nullable: false)] |
| 20 | private string $purpose; |
| 21 | |
| 22 | #[ORM\Column(type: 'string', nullable: false)] |
| 23 | private string $token; |
| 24 | |
| 25 | #[ORM\Column(type: 'datetime', nullable: false)] |
| 26 | private \DateTime $created_at; |
| 27 | |
| 28 | #[ORM\Column(type: 'datetime', nullable: true)] |
| 29 | private ?\DateTime $expires_at; |
| 30 | |
| 31 | #[ORM\Column(type: 'string', nullable: true)] |
| 32 | private ?string $old_token = null; |
| 33 | |
| 34 | #[ORM\Column(type: 'datetime', nullable: true)] |
| 35 | private ?\DateTime $rotated_at = null; |
| 36 | |
| 37 | #[ORM\Version] |
| 38 | #[ORM\Column(type: 'integer', nullable: false, options: ['default' => 1])] |
| 39 | private int $version = 1; |
| 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_id): void { |
| 51 | $this->id = $new_id; |
| 52 | } |
| 53 | |
| 54 | public function getUser(): ?User { |
| 55 | return $this->user; |
| 56 | } |
| 57 | |
| 58 | public function setUser(?User $new_user): void { |
| 59 | $this->user = $new_user; |
| 60 | } |
| 61 | |
| 62 | public function getPurpose(): string { |
| 63 | return $this->purpose; |
| 64 | } |
| 65 | |
| 66 | public function setPurpose(string $new_purpose): void { |
| 67 | $this->purpose = $new_purpose; |
| 68 | } |
| 69 | |
| 70 | public function getToken(): string { |
| 71 | return $this->token; |
| 72 | } |
| 73 | |
| 74 | public function setToken(string $new_token): void { |
| 75 | $this->token = $new_token; |
| 76 | } |
| 77 | |
| 78 | public function getCreatedAt(): \DateTime { |
| 79 | return $this->created_at; |
| 80 | } |
| 81 | |
| 82 | public function setCreatedAt(\DateTime $new_created_at): void { |
| 83 | $this->created_at = $new_created_at; |
| 84 | } |
| 85 | |
| 86 | public function getExpiresAt(): ?\DateTime { |
| 87 | return $this->expires_at; |
| 88 | } |
| 89 | |
| 90 | public function setExpiresAt(?\DateTime $new_expires_at): void { |
| 91 | $this->expires_at = $new_expires_at; |
| 92 | } |
| 93 | |
| 94 | public function getOldToken(): ?string { |
| 95 | return $this->old_token; |
| 96 | } |
| 97 | |
| 98 | public function setOldToken(?string $new_old_token): void { |
| 99 | $this->old_token = $new_old_token; |
| 100 | } |
| 101 | |
| 102 | public function getRotatedAt(): ?\DateTime { |
| 103 | return $this->rotated_at; |
| 104 | } |
| 105 | |
| 106 | public function setRotatedAt(?\DateTime $new_rotated_at): void { |
| 107 | $this->rotated_at = $new_rotated_at; |
| 108 | } |
| 109 | |
| 110 | public function getVersion(): int { |
| 111 | return $this->version; |
| 112 | } |
| 113 | |
| 114 | // --- |
| 115 | |
| 116 | public function testOnlyGetField(string $field_name): mixed { |
| 117 | return $this->{$field_name}; |
| 118 | } |
| 119 | } |