Disc   A
last analyzed

Complexity

Total Complexity 15

Size/Duplication

Total Lines 109
Duplicated Lines 0 %

Test Coverage

Coverage 94.44%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 15
eloc 42
dl 0
loc 109
ccs 34
cts 36
cp 0.9444
rs 10
c 1
b 0
f 0

15 Methods

Rating   Name   Duplication   Size   Complexity  
A setLength() 0 4 1
A getId() 0 3 1
A getMbid() 0 3 1
A getSongs() 0 3 1
A getAlbumId() 0 3 1
A setAlbum() 0 4 1
A setAlbumId() 0 4 1
A setNumber() 0 4 1
A getLength() 0 3 1
A getNumber() 0 3 1
A getSongCount() 0 3 1
A setMbid() 0 4 1
A getAlbum() 0 3 1
A addSong() 0 4 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Uxmp\Core\Orm\Model;
6
7
use Doctrine\Common\Collections\ArrayCollection;
8
use Doctrine\Common\Collections\Collection;
9
use Doctrine\DBAL\Types\Types;
10
use Doctrine\ORM\Mapping as ORM;
11
use Doctrine\ORM\Mapping\OrderBy;
12
use Uxmp\Core\Orm\Repository\DiscRepository;
13
14
#[ORM\Entity(repositoryClass: DiscRepository::class)]
15
#[ORM\Table(name: 'disc')]
16
#[ORM\UniqueConstraint(name: 'mbid_discnumber', columns: ['mbid', 'number'])]
17
class Disc implements DiscInterface
18
{
19
    #[ORM\Column(type: Types::INTEGER)]
20
    #[ORM\Id, ORM\GeneratedValue(strategy: 'AUTO')]
21
    private int $id;
22
23
    #[ORM\Column(type: Types::INTEGER)]
24
    private int $album_id;
25
26
    #[ORM\Column(type: Types::INTEGER)]
27
    private int $number;
28
29
    #[ORM\Column(type: Types::STRING, length: 36, nullable: true)]
30
    private ?string $mbid = null;
31
32
    #[ORM\Column(type: Types::INTEGER, length: 6)]
33
    private int $length = 0;
34
35
    #[ORM\ManyToOne(targetEntity: AlbumInterface::class, inversedBy: 'discs')]
36
    #[ORM\JoinColumn(name: 'album_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')]
37
    private AlbumInterface $album;
38
39
    /** @var Collection<int, SongInterface> */
40
    #[ORM\OneToMany(mappedBy: 'disc', targetEntity: SongInterface::class, cascade: ['ALL'], indexBy: 'id')]
41
    #[OrderBy(['track_number' => 'ASC'])]
42
    private Collection $songs;
43
44 7
    public function __construct()
45
    {
46 7
        $this->songs = new ArrayCollection();
47
    }
48
49
    public function getId(): int
50
    {
51
        return $this->id;
52
    }
53
54 1
    public function getSongs(): iterable
55
    {
56 1
        return $this->songs;
57
    }
58
59 1
    public function addSong(SongInterface $song): DiscInterface
60
    {
61 1
        $this->songs->add($song);
62 1
        return $this;
63
    }
64
65 1
    public function getMbid(): ?string
66
    {
67 1
        return $this->mbid;
68
    }
69
70 1
    public function setMbid(?string $mbid): DiscInterface
71
    {
72 1
        $this->mbid = $mbid;
73 1
        return $this;
74
    }
75
76 1
    public function getAlbumId(): int
77
    {
78 1
        return $this->album_id;
79
    }
80
81 1
    public function setAlbumId(int $album_id): DiscInterface
82
    {
83 1
        $this->album_id = $album_id;
84 1
        return $this;
85
    }
86
87 1
    public function getNumber(): int
88
    {
89 1
        return $this->number;
90
    }
91
92 1
    public function setNumber(int $number): DiscInterface
93
    {
94 1
        $this->number = $number;
95 1
        return $this;
96
    }
97
98 1
    public function getAlbum(): AlbumInterface
99
    {
100 1
        return $this->album;
101
    }
102
103 1
    public function setAlbum(AlbumInterface $album): DiscInterface
104
    {
105 1
        $this->album = $album;
106 1
        return $this;
107
    }
108
109 1
    public function getLength(): int
110
    {
111 1
        return $this->length;
112
    }
113
114 1
    public function setLength(int $length): DiscInterface
115
    {
116 1
        $this->length = $length;
117 1
        return $this;
118
    }
119
120 1
    public function getSongCount(): int
121
    {
122 1
        return $this->songs->count();
123
    }
124
}
125