Test Setup Failed
Push — main ( 7bb2c5...c5b0e8 )
by Daniel
03:55
created

Artist::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
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
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, length: 32, unique: true, nullable: true)]
26
    private ?string $mbid = null;
27
28
    /**
29
     * @var Collection<int, AlbumInterface>
30
     */
31
    #[ORM\OneToMany(mappedBy: 'artist', targetEntity: Album::class, cascade: ['ALL'], indexBy: 'id')]
32
    private Collection $albums;
33
34
    #[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
35
    private \DateTimeInterface $last_modified;
36
37 7
    #[Pure]
38
    public function __construct()
39
    {
40 7
        $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 getAlbums(): iterable
60
    {
61 1
        return $this->albums;
62
    }
63
64 1
    public function addAlbum(AlbumInterface $album): ArtistInterface
65
    {
66 1
        $this->albums->add($album);
67 1
        return $this;
68
    }
69
70 2
    public function getMbid(): ?string
71
    {
72 2
        return $this->mbid;
73
    }
74
75 2
    public function setMbid(?string $mbid): ArtistInterface
76
    {
77 2
        $this->mbid = $mbid;
78 2
        return $this;
79
    }
80
81 1
    #[Pure]
82
    public function getArtItemType(): string
83
    {
84 1
        return 'artist';
85
    }
86
87 1
    #[Pure]
88
    public function getArtItemId(): ?string
89
    {
90 1
        return $this->getMbid();
91
    }
92
93 1
    public function getLastModified(): ?\DateTimeInterface
94
    {
95 1
        return $this->last_modified;
96
    }
97
98 1
    public function setLastModified(\DateTimeInterface $last_modified): ArtistInterface
99
    {
100 1
        $this->last_modified = $last_modified;
101 1
        return $this;
102
    }
103
104
    public function getAlbumCount(): int
105
    {
106
        return $this->albums->count();
107
    }
108
}
109