Completed
Push — master ( 665a2d...66f2ad )
by Valentyn
03:38
created

UserWatchedMovie::updateUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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