Completed
Push — master ( d44c39...321b0a )
by Valentyn
04:27
created

UserWatchedMovie   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 54.55%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 48
ccs 6
cts 11
cp 0.5455
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getUser() 0 4 1
A updateUser() 0 4 1
A getId() 0 4 1
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
     * @Groups({"list"})
33
     */
34
    private $user;
35
36
    /**
37
     * UserWatchedMovies constructor.
38
     *
39
     * @param User                    $user
40
     * @param Movie                   $movie
41
     * @param float|null              $vote
42
     * @param \DateTimeInterface|null $watchedAt
43
     *
44
     * @throws \Exception
45
     */
46 7
    public function __construct(User $user, Movie $movie, ?float $vote, ?\DateTimeInterface $watchedAt)
47
    {
48 7
        $this->user = $user;
49 7
        parent::__construct($movie, $vote, $watchedAt);
50 7
    }
51
52
    public function getId(): ?int
53
    {
54
        return $this->id;
55
    }
56
57 2
    public function getUser(): ?User
58
    {
59 2
        return $this->user;
60
    }
61
62
    public function updateUser(User $user)
63
    {
64
        $this->user = $user;
65
    }
66
}
67