Passed
Push — develop ( 5b9941...3aaa0d )
by BENARD
08:32
created

Twitch::setName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
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\TwitchRepository;
13
use Symfony\Component\Serializer\Annotation\Groups;
14
use Symfony\Component\Validator\Constraints as Assert;
15
16
#[ORM\Table(name:'pnt_twitch')]
17
#[ORM\Entity(repositoryClass: TwitchRepository::class)]
18
#[ApiResource(
19
    operations: [
20
        new GetCollection(),
21
        new Get(),
22
        new Get(
23
            uriTemplate: '/twitches/{id}/get-stream',
24
            controller: GetStream::class,
25
        ),
26
    ],
27
    normalizationContext: ['groups' => ['twitch:read']
28
    ]
29
)]
30
class Twitch
31
{
32
    #[ORM\Id, ORM\Column, ORM\GeneratedValue]
33
    private int $id;
34
35
    #[Groups(['twitch:read'])]
36
    #[Assert\Length(max: 255)]
37
    #[ORM\Column(length: 255, nullable: false)]
38
    private string $name;
39
40
    #[Groups(['twitch:read'])]
41
    #[Assert\Length(max: 255)]
42
    #[ORM\Column(length: 255, nullable: false)]
43
    private string $channel;
44
45
    public function getId(): int
46
    {
47
        return $this->id;
48
    }
49
50
    public function setId(int $id): void
51
    {
52
        $this->id = $id;
53
    }
54
55
    public function getName(): string
56
    {
57
        return $this->name;
58
    }
59
60
    public function setName(string $name): void
61
    {
62
        $this->name = $name;
63
    }
64
65
    public function getChannel(): string
66
    {
67
        return $this->channel;
68
    }
69
70
    public function setChannel(string $channel): void
71
    {
72
        $this->channel = $channel;
73
    }
74
75
    public function __toString()
76
    {
77
        return $this->getName();
78
    }
79
}
80