ChartLib   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 9
eloc 28
c 0
b 0
f 0
dl 0
loc 75
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 3 1
A getName() 0 3 1
A getType() 0 3 1
A setId() 0 3 1
A setChart() 0 3 1
A getId() 0 3 1
A setName() 0 3 1
A setType() 0 3 1
A getChart() 0 3 1
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