Passed
Push — main ( ab47dd...702890 )
by Daniel
12:30
created

Artist::setTitle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
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\ArtistRepository")
13
 * @Table(name="artist")
14
 */
15
class Artist implements ArtistInterface
16
{
17
    /**
18
     * @Id
19
     * @Column(type="integer")
20
     * @GeneratedValue
21
     */
22
    private int $id;
23
24
    /**
25
     * @Column(type="string", nullable=true)
26
     */
27
    private ?string $title = null;
28
29
    /**
30
     * @Column(type="string", length="32", nullable=true, unique=true)
31
     */
32
    private ?string $mbid = null;
33
34
    /**
35
     * @OneToMany(targetEntity="Album", mappedBy="artist", cascade={"ALL"}, indexBy="id")
36
     *
37
     * @var Collection<int, AlbumInterface>
38
     */
39
    private Collection $albums;
40
41 1
    #[Pure]
42
    public function __construct()
43
    {
44 1
        $this->albums = new ArrayCollection();
45 1
    }
46
47
    public function getId(): int
48
    {
49
        return $this->id;
50
    }
51
52
    public function getTitle(): ?string
53
    {
54
        return $this->title;
55
    }
56
57
    public function setTitle(?string $title): ArtistInterface
58
    {
59
        $this->title = $title;
60
        return $this;
61
    }
62
63
    public function getAlbums(): iterable
64
    {
65
        return $this->albums;
66
    }
67
68
    public function addAlbum(AlbumInterface $album): ArtistInterface
69
    {
70
        $this->albums->add($album);
71
        return $this;
72
    }
73
74
    public function getMbid(): ?string
75
    {
76
        return $this->mbid;
77
    }
78
79
    public function setMbid(?string $mbid): ArtistInterface
80
    {
81
        $this->mbid = $mbid;
82
        return $this;
83
    }
84
85
    #[Pure]
86
    public function getArtItemType(): string
87
    {
88
        return 'artist';
89
    }
90
91
    #[Pure]
92
    public function getArtItemId(): ?string
93
    {
94
        return $this->getMbid();
95
    }
96
97
    public function getLastModified(): ?\DateTimeInterface
98
    {
99
        return null;
100
    }
101
}
102