ChartLib::getName()   A
last analyzed

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
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VideoGamesRecords\CoreBundle\Entity;
6
7
use ApiPlatform\Metadata\ApiResource;
8
use ApiPlatform\Metadata\Get;
9
use Doctrine\ORM\Mapping as ORM;
10
use Gedmo\Timestampable\Traits\TimestampableEntity;
11
use Symfony\Component\Validator\Constraints as Assert;
12
use VideoGamesRecords\CoreBundle\Repository\ChartLibRepository;
13
14
#[ORM\Table(name:'vgr_chartlib')]
15
#[ORM\Entity(repositoryClass: ChartLibRepository::class)]
16
#[ApiResource(
17
    operations: [
18
        new Get()
19
    ],
20
    normalizationContext: ['groups' => ['chart-lib:read']]
21
)]
22
class ChartLib
23
{
24
    use TimestampableEntity;
25
26
    #[ORM\Id, ORM\Column, ORM\GeneratedValue]
27
    private ?int $id = null;
28
29
    #[Assert\Length(max: 100)]
30
    #[ORM\Column(length: 100, nullable: true)]
31
    private ?string $name;
32
33
    #[ORM\ManyToOne(targetEntity: Chart::class, inversedBy: 'libs')]
34
    #[ORM\JoinColumn(name:'chart_id', referencedColumnName:'id', nullable:false, onDelete:'CASCADE')]
35
    private Chart $chart;
36
37
38
    #[ORM\ManyToOne(targetEntity: ChartType::class, fetch: 'EAGER')]
39
    #[ORM\JoinColumn(name:'type_id', referencedColumnName:'id', nullable:false)]
40
    private ChartType $type;
41
42
43
    public function setName(?string $name = null): void
44
    {
45
        $this->name = $name;
46
    }
47
48
    public function getName(): ?string
49
    {
50
        return $this->name;
51
    }
52
53
    public function getId(): ?int
54
    {
55
        return $this->id;
56
    }
57
58
    public function setId(int $id): void
59
    {
60
        $this->id = $id;
61
    }
62
63
    public function setChart(Chart $chart): void
64
    {
65
        $this->chart = $chart;
66
    }
67
68
    public function getChart(): Chart
69
    {
70
        return $this->chart;
71
    }
72
73
    public function setType(ChartType $type): void
74
    {
75
        $this->type = $type;
76
    }
77
78
    public function getType(): ChartType
79
    {
80
        return $this->type;
81
    }
82
83
    /**
84
     * @return string
85
     */
86
    public function __toString()
87
    {
88
        return sprintf('%s [%s]', $this->getType()->getName(), $this->id);
89
    }
90
}
91