Passed
Push — main ( 6f91e7...b3043b )
by Daniel
04:24
created

Disc::setNumber()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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 JetBrains\PhpStorm\Pure;
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: 32, 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: Album::class, inversedBy: 'discs')]
36
    #[ORM\JoinColumn(name: 'album_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
37
    private AlbumInterface $album;
38
39
    /**
40
     * @var Collection<int, SongInterface>
41
     */
42
    #[ORM\OneToMany(mappedBy: 'disc', targetEntity: Song::class, cascade: ['ALL'], indexBy: 'id')]
43
    private Collection $songs;
44
45 7
    #[Pure]
46
    public function __construct()
47
    {
48 7
        $this->songs = new ArrayCollection();
49
    }
50
51
    public function getId(): int
52
    {
53
        return $this->id;
54
    }
55
56 1
    public function getSongs(): iterable
57
    {
58 1
        return $this->songs;
59
    }
60
61 1
    public function addSong(SongInterface $song): DiscInterface
62
    {
63 1
        $this->songs->add($song);
64 1
        return $this;
65
    }
66
67 1
    public function getMbid(): ?string
68
    {
69 1
        return $this->mbid;
70
    }
71
72 1
    public function setMbid(?string $mbid): DiscInterface
73
    {
74 1
        $this->mbid = $mbid;
75 1
        return $this;
76
    }
77
78 1
    public function getAlbumId(): int
79
    {
80 1
        return $this->album_id;
81
    }
82
83 1
    public function setAlbumId(int $album_id): DiscInterface
84
    {
85 1
        $this->album_id = $album_id;
86 1
        return $this;
87
    }
88
89 1
    public function getNumber(): int
90
    {
91 1
        return $this->number;
92
    }
93
94 1
    public function setNumber(int $number): DiscInterface
95
    {
96 1
        $this->number = $number;
97 1
        return $this;
98
    }
99
100 1
    public function getAlbum(): AlbumInterface
101
    {
102 1
        return $this->album;
103
    }
104
105 1
    public function setAlbum(AlbumInterface $album): DiscInterface
106
    {
107 1
        $this->album = $album;
108 1
        return $this;
109
    }
110
111 1
    public function getLength(): int
112
    {
113 1
        return $this->length;
114
    }
115
116 1
    public function setLength(int $length): DiscInterface
117
    {
118 1
        $this->length = $length;
119 1
        return $this;
120
    }
121
122 1
    public function getSongCount(): int
123
    {
124 1
        return $this->songs->count();
125
    }
126
}
127