Passed
Push — develop ( 8a0cc8...8f1aed )
by BENARD
02:07
created

Channel::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProjetNormandie\TwitchBundle\Entity;
6
7
use ApiPlatform\Metadata\ApiResource;
8
use ApiPlatform\Metadata\Get;
9
use ApiPlatform\Metadata\GetCollection;
10
use Doctrine\ORM\Mapping as ORM;
11
use ProjetNormandie\TwitchBundle\Controller\GetStream;
12
use ProjetNormandie\TwitchBundle\Repository\ChannelRepository;
13
use Symfony\Component\Serializer\Annotation\Groups;
14
use Symfony\Component\Validator\Constraints as Assert;
15
16
#[ORM\Table(name:'pnt_channel')]
17
#[ORM\Entity(repositoryClass: ChannelRepository::class)]
18
#[ApiResource(
19
    routePrefix: '/twitch',
20
    operations: [
21
        new GetCollection(),
22
        new Get(),
23
        new Get(
24
            uriTemplate: '/channels/{id}/get-stream',
25
            controller: GetStream::class,
26
        ),
27
    ],
28
    normalizationContext: ['groups' => ['twitch:read']
29
    ]
30
)]
31
class Channel
32
{
33
    #[ORM\Id, ORM\Column, ORM\GeneratedValue]
34
    private int $id;
35
36
    #[Groups(['twitch:read'])]
37
    #[Assert\Length(max: 255)]
38
    #[ORM\Column(length: 255, nullable: false)]
39
    private string $name;
40
41
    #[Groups(['twitch:read'])]
42
    #[Assert\Length(max: 255)]
43
    #[ORM\Column(length: 255, nullable: false)]
44
    private string $username;
45
46
    public function getId(): int
47
    {
48
        return $this->id;
49
    }
50
51
    public function setId(int $id): void
52
    {
53
        $this->id = $id;
54
    }
55
56
    public function getName(): string
57
    {
58
        return $this->name;
59
    }
60
61
    public function setName(string $name): void
62
    {
63
        $this->name = $name;
64
    }
65
66
    public function getUsername(): string
67
    {
68
        return $this->username;
69
    }
70
71
    public function setUsername(string $username): void
72
    {
73
        $this->username = $username;
74
    }
75
76
    public function __toString()
77
    {
78
        return $this->getName();
79
    }
80
}
81