Passed
Push — main ( 0ace76...960e41 )
by Daniel
04:09
created

Artist::getTitle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Uxmp\Core\Orm\Model;
6
7
use DateTimeInterface;
8
use Doctrine\Common\Collections\ArrayCollection;
9
use Doctrine\Common\Collections\Collection;
10
use Doctrine\DBAL\Types\Types;
11
use Doctrine\ORM\Mapping as ORM;
12
use Uxmp\Core\Orm\Repository\ArtistRepository;
13
14
#[ORM\Entity(repositoryClass: ArtistRepository::class)]
15
#[ORM\Table(name: 'artist')]
16
class Artist implements ArtistInterface
17
{
18
    #[ORM\Column(type: Types::INTEGER)]
19
    #[ORM\Id, ORM\GeneratedValue(strategy: 'AUTO')]
20
    private int $id;
21
22
    #[ORM\Column(type: Types::STRING, nullable: true)]
23
    private ?string $title = null;
24
25
    #[ORM\Column(type: Types::STRING, nullable: true)]
26
    private ?string $searchTitle = '';
27
28
    #[ORM\Column(type: Types::STRING, length: 36, unique: true, nullable: true)]
29
    private ?string $mbid = null;
30
31
    /** @var Collection<int, AlbumInterface> */
32
    #[ORM\OneToMany(mappedBy: 'artist', targetEntity: AlbumInterface::class, cascade: ['ALL'], indexBy: 'id')]
33
    private Collection $albums;
34
35
    #[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
36
    private DateTimeInterface $last_modified;
37
38 9
    public function __construct()
39
    {
40 9
        $this->albums = new ArrayCollection();
41
    }
42
43
    public function getId(): int
44
    {
45
        return $this->id;
46
    }
47
48 1
    public function getTitle(): ?string
49
    {
50 1
        return $this->title;
51
    }
52
53 1
    public function setTitle(?string $title): ArtistInterface
54
    {
55 1
        $this->title = $title;
56 1
        return $this;
57
    }
58
59 1
    public function getSearchTitle(): string
60
    {
61 1
        return (string) $this->searchTitle;
62
    }
63
64 1
    public function setSearchTitle(string $searchTitle): ArtistInterface
65
    {
66 1
        $this->searchTitle = $searchTitle;
67 1
        return $this;
68
    }
69
70 1
    public function getAlbums(): iterable
71
    {
72 1
        return $this->albums;
73
    }
74
75 1
    public function addAlbum(AlbumInterface $album): ArtistInterface
76
    {
77 1
        $this->albums->add($album);
78 1
        return $this;
79
    }
80
81 2
    public function getMbid(): ?string
82
    {
83 2
        return $this->mbid;
84
    }
85
86 2
    public function setMbid(?string $mbid): ArtistInterface
87
    {
88 2
        $this->mbid = $mbid;
89 2
        return $this;
90
    }
91
92 1
    public function getArtItemType(): string
93
    {
94 1
        return 'artist';
95
    }
96
97 1
    public function getArtItemId(): ?string
98
    {
99 1
        return $this->getMbid();
100
    }
101
102 1
    public function getLastModified(): ?DateTimeInterface
103
    {
104 1
        return $this->last_modified;
105
    }
106
107 1
    public function setLastModified(DateTimeInterface $last_modified): ArtistInterface
108
    {
109 1
        $this->last_modified = $last_modified;
110 1
        return $this;
111
    }
112
113 1
    public function getAlbumCount(): int
114
    {
115 1
        return $this->albums->count();
116
    }
117
}
118