Completed
Push — master ( 57fac9...43d856 )
by Valentyn
02:37
created

UserWatchedMovie::getId()   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
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace App\Users\Entity;
5
6
use App\Movies\Entity\Movie;
7
use App\Movies\Entity\WatchedMovie;
8
use App\Users\Entity\User;
9
use Doctrine\ORM\Mapping as ORM;
10
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
11
use Symfony\Component\Validator\Constraints as Assert;
12
use Symfony\Component\Serializer\Annotation\Groups;
13
14
/**
15
 * @ORM\Entity(repositoryClass="App\Users\Repository\WatchedMovieRepository")
16
 * @ORM\Table(name="users_watched_movies",
17
 *     uniqueConstraints={
18
 *      @ORM\UniqueConstraint(name="idx_UserWatchedMovie_user_id_movie_id", columns={"user_id", "movie_id"})
19
 *     })
20
 */
21
class UserWatchedMovie extends WatchedMovie
22
{
23
    /**
24
     * @ORM\Id()
25
     * @ORM\GeneratedValue()
26
     * @ORM\Column(type="integer")
27
     * @Groups({"list"})
28
     */
29
    private $id;
30
31
    /**
32
     * @ORM\ManyToOne(targetEntity="App\Users\Entity\User")
33
     * @ORM\JoinColumn(nullable=false)
34
     */
35
    private $user;
36
37
    /**
38
     * UserWatchedMovies constructor.
39
     * @param User $user
40
     * @param Movie $movie
41
     * @param float|null $vote
42
     * @param \DateTimeInterface|null $watchedAt
43
     * @throws \Exception
44
     */
45 3
    public function __construct(User $user, Movie $movie, ?float $vote, ?\DateTimeInterface $watchedAt)
46
    {
47 3
        $this->user = $user;
48 3
        parent::__construct($movie, $vote, $watchedAt);
49 3
    }
50
51
    public function getId(): ?int
52
    {
53
        return $this->id;
54
    }
55
56 1
    public function getUser(): ?User
57
    {
58 1
        return $this->user;
59
    }
60
61
    public function updateUser(User $user)
62
    {
63
        $this->user = $user;
64
    }
65
}