Passed
Push — main ( c3468e...e5e2c1 )
by Daniel
04:07
created

Disc::addSong()   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 JetBrains\PhpStorm\Pure;
10
11
/**
12
 * @Entity(repositoryClass="\Uxmp\Core\Orm\Repository\DiscRepository")
13
 * @Table(
14
 *     name="disc",
15
 *     uniqueConstraints={
16
 *        @UniqueConstraint(name="mbid_discnumber", columns={"mbid", "number"})
17
 *    }
18
 * )
19
 */
20
class Disc implements DiscInterface
21
{
22
    /**
23
     * @Id
24
     * @Column(type="integer")
25
     * @GeneratedValue
26
     */
27
    private int $id;
28
29
    /**
30
     * @Column(type="integer")
31
     */
32
    private int $album_id;
33
34
    /**
35
     * @Column(type="integer")
36
     */
37
    private int $number;
38
39
    /**
40
     * @Column(type="string", length="32", nullable="true")
41
     */
42
    private ?string $mbid = null;
43
44
    /**
45
     * @Column(type="integer", length="6")
46
     */
47
    private int $length = 0;
48
49
    /**
50
     * @ManyToOne(targetEntity="Album", inversedBy="discs")
51
     * @JoinColumn(name="album_id", referencedColumnName="id", onDelete="CASCADE")
52
     */
53
    private AlbumInterface $album;
54
55
    /**
56
     * @OneToMany(targetEntity="Song", mappedBy="disc", cascade={"ALL"}, indexBy="id")
57
     *
58
     * @var Collection<int, SongInterface>
59
     */
60
    private Collection $songs;
61
62 7
    #[Pure]
63
    public function __construct()
64
    {
65 7
        $this->songs = new ArrayCollection();
66
    }
67
68
    public function getId(): int
69
    {
70
        return $this->id;
71
    }
72
73 1
    public function getSongs(): iterable
74
    {
75 1
        return $this->songs;
76
    }
77
78 1
    public function addSong(SongInterface $song): DiscInterface
79
    {
80 1
        $this->songs->add($song);
81 1
        return $this;
82
    }
83
84 1
    public function getMbid(): ?string
85
    {
86 1
        return $this->mbid;
87
    }
88
89 1
    public function setMbid(?string $mbid): DiscInterface
90
    {
91 1
        $this->mbid = $mbid;
92 1
        return $this;
93
    }
94
95 1
    public function getAlbumId(): int
96
    {
97 1
        return $this->album_id;
98
    }
99
100 1
    public function setAlbumId(int $album_id): DiscInterface
101
    {
102 1
        $this->album_id = $album_id;
103 1
        return $this;
104
    }
105
106 1
    public function getNumber(): int
107
    {
108 1
        return $this->number;
109
    }
110
111 1
    public function setNumber(int $number): DiscInterface
112
    {
113 1
        $this->number = $number;
114 1
        return $this;
115
    }
116
117 1
    public function getAlbum(): AlbumInterface
118
    {
119 1
        return $this->album;
120
    }
121
122 1
    public function setAlbum(AlbumInterface $album): DiscInterface
123
    {
124 1
        $this->album = $album;
125 1
        return $this;
126
    }
127
128 1
    public function getLength(): int
129
    {
130 1
        return $this->length;
131
    }
132
133 1
    public function setLength(int $length): DiscInterface
134
    {
135 1
        $this->length = $length;
136 1
        return $this;
137
    }
138
}
139