Completed
Push — master ( 89f754...0e5042 )
by Michael
03:54
created

Vote::getPoll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace AppBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use AppBundle\Entity\User;
7
use AppBundle\Entity\Poll;
8
use AppBundle\Entity\Choice;
9
use Doctrine\Common\Collections\ArrayCollection;
10
11
/**
12
 * Vote
13
 *
14
 * @ORM\Table(name="votes")
15
 * @ORM\Entity(repositoryClass="AppBundle\Repository\VoteRepository")
16
 */
17
class Vote
18
{
19
    /**
20
     * @var int
21
     *
22
     * @ORM\Column(name="id", type="integer")
23
     * @ORM\Id
24
     * @ORM\GeneratedValue(strategy="AUTO")
25
     */
26
    private $id;
27
28
    /**
29
     * @var \Poll
30
     *
31
     * @ORM\ManyToOne(targetEntity="Poll", inversedBy="votes")
32
     * @ORM\JoinColumn(name="poll_id", referencedColumnName="id")
33
     */
34
    private $poll;
35
36
    /**
37
     * @var \User
38
     *
39
     * @ORM\ManyToOne(targetEntity="User", inversedBy="votes")
40
     * @ORM\JoinColumn(name="caster_id", referencedColumnName="id")
41
     */
42
    private $caster;
43
44
    /**
45
     * @var \DateTime
46
     *
47
     * @ORM\Column(name="time", type="datetime")
48
     */
49
    private $time;
50
51
    /**
52
     * @var \Choice
53
     *
54
     * @ORM\ManyToOne(targetEntity="Choice", inversedBy="votes")
55
     * @ORM\JoinColumn(name="choice_id", referencedColumnName="id")
56
     */
57
    private $choice;
58
59
    /**
60
     * Get id
61
     *
62
     * @return integer
63
     */
64
    public function getId(): int
65
    {
66
        return $this->id;
67
    }
68
69
    /**
70
     * Set time
71
     *
72
     * @param \DateTime $time
73
     *
74
     * @return Vote
75
     */
76
    public function setTime(\DateTimeInterface $time)
77
    {
78
        $this->time = $time;
0 ignored issues
show
Documentation Bug introduced by
$time is of type object<DateTimeInterface>, but the property $time was declared to be of type object<DateTime>. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof 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 given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
79
80
        return $this;
81
    }
82
83
    /**
84
     * Get time
85
     *
86
     * @return \DateTime
87
     */
88
    public function getTime(): DateTime
89
    {
90
        return $this->time;
91
    }
92
93
    /**
94
     * Set poll
95
     *
96
     * @param \AppBundle\Entity\Poll $poll
97
     *
98
     * @return Vote
99
     */
100
    public function setPoll(Poll $poll = null)
101
    {
102
        $this->poll = $poll;
0 ignored issues
show
Documentation Bug introduced by
It seems like $poll can also be of type object<AppBundle\Entity\Poll>. However, the property $poll is declared as type object<Poll>. 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...
103
104
        return $this;
105
    }
106
107
    /**
108
     * Get poll
109
     *
110
     * @return \AppBundle\Entity\Poll
111
     */
112
    public function getPoll(): Poll
113
    {
114
        return $this->poll;
115
    }
116
117
    /**
118
     * Set caster
119
     *
120
     * @param \AppBundle\Entity\User $caster
121
     *
122
     * @return Vote
123
     */
124
    public function setCaster(User $caster = null)
125
    {
126
        $this->caster = $caster;
0 ignored issues
show
Documentation Bug introduced by
It seems like $caster can also be of type object<AppBundle\Entity\User>. However, the property $caster is declared as type object<User>. 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...
127
128
        return $this;
129
    }
130
131
    /**
132
     * Get caster
133
     *
134
     * @return \AppBundle\Entity\User
135
     */
136
    public function getCaster(): User
137
    {
138
        return $this->caster;
139
    }
140
141
    /**
142
     * Set choice
143
     *
144
     * @param \AppBundle\Entity\Choice $choice
145
     *
146
     * @return Vote
147
     */
148
    public function setChoice(Choice $choice = null)
149
    {
150
        $this->choice = $choice;
0 ignored issues
show
Documentation Bug introduced by
It seems like $choice can also be of type object<AppBundle\Entity\Choice>. However, the property $choice is declared as type object<Choice>. 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...
151
152
        return $this;
153
    }
154
155
    /**
156
     * Get choice
157
     *
158
     * @return \AppBundle\Entity\Choice
159
     */
160
    public function getChoice(): Choice
161
    {
162
        return $this->choice;
163
    }
164
}
165