Passed
Branch 0.1 (d41d7c)
by Nils
02:15
created

Matchday::getGroup()   A

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 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Torakel\DatabaseBundle\Entity;
3
4
use Doctrine\Common\Collections\ArrayCollection;
5
use Doctrine\ORM\Mapping as ORM;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\Mapping was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
7
/**
8
 * @ORM\Entity
9
 * @ORM\HasLifecycleCallbacks
10
 * @ORM\Entity(repositoryClass="Torakel\DatabaseBundle\Repository\MatchdayRepository")
11
 * @ORM\Table(name="matchday")
12
 */
13
class Matchday
14
{
15
16
    /**
17
     * @var integer
18
     * @ORM\Column(type="integer")
19
     * @ORM\Id
20
     * @ORM\GeneratedValue(strategy="AUTO")
21
     */
22
    private $id;
23
24
    /**
25
     * @var string
26
     * @ORM\Column(type="string")
27
     */
28
    protected $slug;
29
30
    /**
31
     * @var string
32
     * @ORM\Column(type="string")
33
     */
34
    protected $name;
35
36
    /**
37
     * @var \Torakel\DatabaseBundle\Entity\Round
38
     * @ORM\ManyToOne(targetEntity="\Torakel\DatabaseBundle\Entity\Round", inversedBy="matchdays")
39
     * @ORM\JoinColumn(name="round_id", referencedColumnName="id")
40
     */
41
    protected $round;
42
43
    /**
44
     * @var \Torakel\DatabaseBundle\Entity\Round
45
     * @ORM\ManyToOne(targetEntity="\Torakel\DatabaseBundle\Entity\Group", inversedBy="matchdays")
46
     * @ORM\JoinColumn(name="group_id", referencedColumnName="id")
47
     */
48
    protected $group;
49
50
    /**
51
     * @var \Torakel\DatabaseBundle\Entity\MatchdayTable
52
     * @ORM\OneToOne(targetEntity="\Torakel\DatabaseBundle\Entity\MatchdayTable", mappedBy="matchday")
53
     */
54
    protected $matchdayTable;
55
56
    /**
57
     * @var \Doctrine\Common\Collections\ArrayCollection;
58
     * @ORM\OneToMany(targetEntity="\Torakel\DatabaseBundle\Entity\Game", mappedBy="matchday")
59
     */
60
    protected $games;
61
62
    /**
63
     * @var integer
64
     * @ORM\Column(type="integer")
65
     */
66
    protected $position;
67
68
    /**
69
     * @var \DateTime
70
     * @ORM\Column(type="datetime", name="created_at")
71
     */
72
    protected $createdAt;
73
74
    /**
75
     * @var \DateTime
76
     * @ORM\Column(type="datetime", name="updated_at", nullable=true)
77
     */
78
    protected $updatedAt;
79
80
    /**
81
     * Constructor
82
     */
83 6
    public function __construct()
84
    {
85 6
        $this->games = new \Doctrine\Common\Collections\ArrayCollection();
86 6
    }
87
88
    /**
89
     * Get id
90
     *
91
     * @return integer
92
     */
93 1
    public function getId()
94
    {
95 1
        return $this->id;
96
    }
97
98
    /**
99
     * Set slug
100
     *
101
     * @param string $slug
102
     *
103
     * @return Matchday
104
     */
105 1
    public function setSlug($slug)
106
    {
107 1
        $this->slug = $slug;
108
109 1
        return $this;
110
    }
111
112
    /**
113
     * Get slug
114
     *
115
     * @return string
116
     */
117 1
    public function getSlug()
118
    {
119 1
        return $this->slug;
120
    }
121
122
    /**
123
     * Set name
124
     *
125
     * @param string $name
126
     *
127
     * @return Matchday
128
     */
129 1
    public function setName($name)
130
    {
131 1
        $this->name = $name;
132
133 1
        return $this;
134
    }
135
136
    /**
137
     * Get name
138
     *
139
     * @return string
140
     */
141 1
    public function getName()
142
    {
143 1
        return $this->name;
144
    }
145
146
    /**
147
     * Set position
148
     *
149
     * @param integer $position
150
     *
151
     * @return Matchday
152
     */
153 1
    public function setPosition($position)
154
    {
155 1
        $this->position = $position;
156
157 1
        return $this;
158
    }
159
160
    /**
161
     * Get position
162
     *
163
     * @return integer
164
     */
165 1
    public function getPosition()
166
    {
167 1
        return $this->position;
168
    }
169
170
    /**
171
     * Set createdAt
172
     *
173
     * @param \DateTime $createdAt
174
     *
175
     * @return Matchday
176
     */
177 1
    public function setCreatedAt($createdAt)
178
    {
179 1
        $this->createdAt = $createdAt;
180
181 1
        return $this;
182
    }
183
184
    /**
185
     * Get createdAt
186
     *
187
     * @return \DateTime
188
     */
189 1
    public function getCreatedAt()
190
    {
191 1
        return $this->createdAt;
192
    }
193
194
    /**
195
     * Set updatedAt
196
     *
197
     * @param \DateTime $updatedAt
198
     *
199
     * @return Matchday
200
     */
201 1
    public function setUpdatedAt($updatedAt)
202
    {
203 1
        $this->updatedAt = $updatedAt;
204
205 1
        return $this;
206
    }
207
208
    /**
209
     * Get updatedAt
210
     *
211
     * @return \DateTime
212
     */
213 1
    public function getUpdatedAt()
214
    {
215 1
        return $this->updatedAt;
216
    }
217
218
    /**
219
     * Set round
220
     *
221
     * @param \Torakel\DatabaseBundle\Entity\Round $round
222
     *
223
     * @return Matchday
224
     */
225 1
    public function setRound(\Torakel\DatabaseBundle\Entity\Round $round = null)
226
    {
227 1
        $this->round = $round;
228
229 1
        return $this;
230
    }
231
232
    /**
233
     * Get round
234
     *
235
     * @return \Torakel\DatabaseBundle\Entity\Round
236
     */
237 1
    public function getRound()
238
    {
239 1
        return $this->round;
240
    }
241
242
    /**
243
     * Set group
244
     *
245
     * @param \Torakel\DatabaseBundle\Entity\Group $group
246
     *
247
     * @return Matchday
248
     */
249 1
    public function setGroup(\Torakel\DatabaseBundle\Entity\Group $group = null)
250
    {
251 1
        $this->group = $group;
0 ignored issues
show
Documentation Bug introduced by
It seems like $group can also be of type Torakel\DatabaseBundle\Entity\Group. However, the property $group is declared as type Torakel\DatabaseBundle\Entity\Round. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
252
253 1
        return $this;
254
    }
255
256
    /**
257
     * Get group
258
     *
259
     * @return \Torakel\DatabaseBundle\Entity\Group
260
     */
261 1
    public function getGroup()
262
    {
263 1
        return $this->group;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->group returns the type Torakel\DatabaseBundle\Entity\Round which is incompatible with the documented return type Torakel\DatabaseBundle\Entity\Group.
Loading history...
264
    }
265
266
    /**
267
     * Add game
268
     *
269
     * @param \Torakel\DatabaseBundle\Entity\Game $game
270
     *
271
     * @return Matchday
272
     */
273 1
    public function addGame(\Torakel\DatabaseBundle\Entity\Game $game)
274
    {
275 1
        $this->games[] = $game;
276
277 1
        return $this;
278
    }
279
280
    /**
281
     * Remove game
282
     *
283
     * @param \Torakel\DatabaseBundle\Entity\Game $game
284
     */
285 1
    public function removeGame(\Torakel\DatabaseBundle\Entity\Game $game)
286
    {
287 1
        $this->games->removeElement($game);
288 1
    }
289
290
    /**
291
     * Get games
292
     *
293
     * @return \Doctrine\Common\Collections\Collection
294
     */
295 1
    public function getGames()
296
    {
297 1
        return $this->games;
298
    }
299
300
    /**
301
     * @ORM\PrePersist
302
     */
303 1
    public function prePersist()
304
    {
305 1
        $this->createdAt = new \DateTime();
306 1
    }
307
308
    /**
309
     * @ORM\PreUpdate
310
     */
311 1
    public function preUpdate()
312
    {
313 1
        $this->updatedAt = new \DateTime();
314 1
    }
315
316
    /**
317
     * Set matchdayTable
318
     *
319
     * @param \Torakel\DatabaseBundle\Entity\MatchdayTable $matchdayTable
320
     *
321
     * @return Matchday
322
     */
323 1
    public function setMatchdayTable(\Torakel\DatabaseBundle\Entity\MatchdayTable $matchdayTable = null)
324
    {
325 1
        $this->matchdayTable = $matchdayTable;
326
327 1
        return $this;
328
    }
329
330
    /**
331
     * Get matchdayTable
332
     *
333
     * @return \Torakel\DatabaseBundle\Entity\MatchdayTable
334
     */
335 1
    public function getMatchdayTable()
336
    {
337 1
        return $this->matchdayTable;
338
    }
339
}
340