Review::setBook()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
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
/*
4
 * (c) Lukasz D. Tulikowski <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace App\Entity;
13
14
use App\Traits\IdColumnTrait;
15
use App\Traits\TimeAwareTrait;
16
use Doctrine\ORM\Mapping as ORM;
17
use JMS\Serializer\Annotation as JMS;
18
use Symfony\Component\Validator\Constraints as Assert;
19
20
/**
21
 * @ORM\Entity(repositoryClass="App\Repository\ReviewRepository")
22
 *
23
 * @JMS\ExclusionPolicy("ALL")
24
 */
25
class Review
26
{
27
    use IdColumnTrait;
28
    use TimeAwareTrait;
29
30
    /**
31
     * @var string
32
     *
33
     * @ORM\Column(type="text")
34
     *
35
     * @Assert\NotBlank
36
     *
37
     * @JMS\Expose
38
     */
39
    protected $body;
40
41
    /**
42
     * @var int
43
     *
44
     * @ORM\Column(type="integer")
45
     *
46
     * @Assert\NotBlank
47
     *
48
     * @JMS\Expose
49
     */
50
    protected $rating;
51
52
    /**
53
     * @var User
54
     *
55
     * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="reviews", cascade={"persist", "remove"})
56
     *
57
     * @JMS\Expose
58
     * @JMS\Groups("author")
59
     */
60
    protected $author;
61
62
    /**
63
     * @var \DateTimeInterface
64
     *
65
     * @ORM\Column(type="date")
66
     *
67
     * @Assert\NotBlank
68
     *
69
     * @JMS\Expose
70
     */
71
    protected $publicationDate;
72
73
    /**
74
     * @var Book
75
     *
76
     * @ORM\ManyToOne(targetEntity="App\Entity\Book", inversedBy="reviews", cascade={"persist"})
77
     *
78
     * @JMS\Expose
79
     * @JMS\Groups("books")
80
     */
81
    protected $book;
82
83
    /**
84
     * @var Movie
85
     *
86
     * @ORM\ManyToOne(targetEntity="App\Entity\Movie", inversedBy="reviews", cascade={"persist"})
87
     *
88
     * @JMS\Expose
89
     * @JMS\Groups("movies")
90
     */
91
    protected $movie;
92
93
    /**
94
     * @return string|null
95
     */
96 3
    public function getBody(): ?string
97
    {
98 3
        return $this->body;
99
    }
100
101
    /**
102
     * @param string $body
103
     *
104
     * @return Review
105
     */
106 2
    public function setBody(string $body): self
107
    {
108 2
        $this->body = $body;
109
110 2
        return $this;
111
    }
112
113
    /**
114
     * @return int|null
115
     */
116 3
    public function getRating(): ?int
117
    {
118 3
        return $this->rating;
119
    }
120
121
    /**
122
     * @param int $rating
123
     *
124
     * @return Review
125
     */
126 3
    public function setRating(int $rating): self
127
    {
128 3
        $this->rating = $rating;
129
130 3
        return $this;
131
    }
132
133
    /**
134
     * @return \DateTimeInterface|null
135
     */
136 3
    public function getPublicationDate(): ?\DateTimeInterface
137
    {
138 3
        return $this->publicationDate;
139
    }
140
141
    /**
142
     * @param \DateTimeInterface $publicationDate
143
     *
144
     * @return Review
145
     */
146 2
    public function setPublicationDate(?\DateTimeInterface $publicationDate): self
147
    {
148 2
        $this->publicationDate = $publicationDate;
149
150 2
        return $this;
151
    }
152
153
    /**
154
     * @return User|null
155
     */
156 3
    public function getAuthor(): ?User
157
    {
158 3
        return $this->author;
159
    }
160
161
    /**
162
     * @param User|null $author
163
     *
164
     * @return Review
165
     */
166 2
    public function setAuthor(?User $author): self
167
    {
168 2
        $this->author = $author;
169
170 2
        return $this;
171
    }
172
173
    /**
174
     * @return Book|null
175
     */
176
    public function getBook(): ?Book
177
    {
178
        return $this->book;
179
    }
180
181
    /**
182
     * @param Book|null $book
183
     *
184
     * @return Review
185
     */
186
    public function setBook(?Book $book): self
187
    {
188
        $this->book = $book;
189
190
        return $this;
191
    }
192
193
    /**
194
     * @return Movie|null
195
     */
196
    public function getMovie(): ?Movie
197
    {
198
        return $this->movie;
199
    }
200
201
    /**
202
     * @param Movie|null $movie
203
     *
204
     * @return Review
205
     */
206
    public function setMovie(?Movie $movie): self
207
    {
208
        $this->movie = $movie;
209
210
        return $this;
211
    }
212
}
213