AbstractVote::setUser()   A
last analyzed

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
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of the MsalsasVotingBundle package.
5
 *
6
 * (c) Manolo Salsas
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Msalsas\VotingBundle\Entity\Vote;
13
14
15
use Symfony\Component\Security\Core\User\UserInterface;
16
17
abstract class AbstractVote
18
{
19
    /**
20
     * @var integer
21
     */
22
    protected $id;
23
24
    /**
25
     * @var UserInterface|null|string
26
     */
27
    protected $user = null;
28
29
    /**
30
     * @var integer
31
     */
32
    protected $reference;
33
34
    /**
35
     * @var string
36
     */
37
    protected $userIP;
38
39
    /**
40
     * @return int
41
     */
42 2
    public function getId(): int
43
    {
44 2
        return $this->id;
45
    }
46
47
    /**
48
     * @param int $id
49
     */
50 2
    public function setId(int $id)
51
    {
52 2
        $this->id = $id;
53 2
    }
54
55
    /**
56
     * @return string|UserInterface
57
     */
58 2
    public function getUser()
59
    {
60 2
        return $this->user;
61
    }
62
63
    /**
64
     * @param string|UserInterface $user
65
     */
66 9
    public function setUser($user)
67
    {
68 9
        $this->user = $user;
69 9
    }
70
71
    /**
72
     * @return int
73
     */
74 2
    public function getReference(): int
75
    {
76 2
        return $this->reference;
77
    }
78
79
    /**
80
     * @param int $reference
81
     */
82 9
    public function setReference(int $reference)
83
    {
84 9
        $this->reference = $reference;
85 9
    }
86
87
    /**
88
     * @return string|null
89
     */
90 2
    public function getUserIP(): string
91
    {
92 2
        return $this->userIP;
93
    }
94
95
    /**
96
     * @param string|null $userIP
97
     */
98 9
    public function setUserIP(string $userIP = null)
99
    {
100 9
        $this->userIP = $userIP;
101 9
    }
102
103 2
    public function isPositive()
104
    {
105 2
        if (get_class($this) === 'Msalsas\VotingBundle\Entity\VotePositive') {
106 1
            return true;
107
        }
108
109 1
        return false;
110
    }
111
}