TemporaryPlaylist::getOwner()   A
last analyzed

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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Uxmp\Core\Orm\Model;
6
7
use Doctrine\DBAL\Types\Types;
8
use Doctrine\ORM\Mapping as ORM;
9
use Ramsey\Uuid\Doctrine\UuidType;
10
use Uxmp\Core\Orm\Repository\TemporaryPlaylistRepository;
11
12
#[ORM\Entity(repositoryClass: TemporaryPlaylistRepository::class)]
13
#[ORM\Table(name: 'temporary_playlist')]
14
class TemporaryPlaylist implements TemporaryPlaylistInterface
15
{
16
    #[ORM\Column(type: UuidType::NAME, unique: true)]
17
    #[ORM\Id, ORM\GeneratedValue(strategy: 'NONE')]
18
    private string $id;
19
20
    #[ORM\Column(type: Types::INTEGER, options: ['default' => 0])]
21
    private int $owner_user_id = 0;
0 ignored issues
show
introduced by
The private property $owner_user_id is not used, and could be removed.
Loading history...
22
23
    #[ORM\Column(type: Types::INTEGER, options: ['default' => 0])]
24
    private int $song_count = 0;
25
26
    /** @var array<int> */
27
    #[ORM\Column(type: Types::JSON, options: ['default' => '[]'])]
28
    private array $song_list = [];
29
30
    #[ORM\Column(type: Types::INTEGER, options: ['default' => 0])]
31
    private int $playback_offset = 0;
32
33
    #[ORM\ManyToOne(targetEntity: UserInterface::class)]
34
    #[ORM\JoinColumn(name: 'owner_user_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
35
    private UserInterface $owner;
36
37 1
    public function getId(): string
38
    {
39 1
        return $this->id;
40
    }
41
42 1
    public function setId(string $id): TemporaryPlaylistInterface
43
    {
44 1
        $this->id = $id;
45 1
        return $this;
46
    }
47
48 1
    public function getOwner(): UserInterface
49
    {
50 1
        return $this->owner;
51
    }
52
53 1
    public function setOwner(UserInterface $owner): TemporaryPlaylistInterface
54
    {
55 1
        $this->owner = $owner;
56 1
        return $this;
57
    }
58
59
    /**
60
     * @return array<int>
61
     */
62 2
    public function getSongList(): array
63
    {
64 2
        return $this->song_list;
65
    }
66
67
    /**
68
     * @param array<int> $songList
69
     */
70 2
    public function setSongList(array $songList): TemporaryPlaylistInterface
71
    {
72 2
        $this->song_list = $songList;
73 2
        return $this;
74
    }
75
76 2
    public function getSongCount(): int
77
    {
78 2
        return $this->song_count;
79
    }
80
81 2
    public function setSongCount(int $songCount): TemporaryPlaylistInterface
82
    {
83 2
        $this->song_count = $songCount;
84 2
        return $this;
85
    }
86
87 1
    public function getPlaybackOffset(): int
88
    {
89 1
        return $this->playback_offset;
90
    }
91
92 1
    public function setPlaybackOffset(int $playbackOffset): TemporaryPlaylistInterface
93
    {
94 1
        $this->playback_offset = $playbackOffset;
95 1
        return $this;
96
    }
97
98
    /**
99
     * Updates the song list and also sets the song count
100
     *
101
     * @param array<int> $songList
102
     */
103 1
    public function updateSongList(
104
        array $songList
105
    ): TemporaryPlaylistInterface {
106 1
        $this->setSongList($songList);
107 1
        $this->setSongCount(count($songList));
108
109 1
        return $this;
110
    }
111
}
112