Passed
Push — main ( b86851...42a9a8 )
by Daniel
04:14
created

Artist::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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