Completed
Push — master ( 9db26b...a06708 )
by Michael
04:04
created

User   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 136
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 19.23%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 9
lcom 2
cbo 2
dl 0
loc 136
ccs 5
cts 26
cp 0.1923
rs 10
c 4
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A setName() 0 6 1
A getName() 0 4 1
A addCreatedPoll() 0 6 1
A getCreatedPolls() 0 4 1
A addVote() 0 6 1
A getVotes() 0 4 1
A removeCreatedPoll() 0 4 1
A removeVote() 0 4 1
A __construct() 0 7 1
1
<?php
2
3
namespace AppBundle\Entity;
4
5
use FOS\UserBundle\Model\User as BaseUser;
6
use Doctrine\ORM\Mapping as ORM;
7
use Doctrine\Common\Collections\ArrayCollection;
8
9
/**
10
 * @ORM\Entity
11
 * @ORM\Table(name="users")
12
 */
13
class User extends BaseUser
14
{
15
    /**
16
     * @ORM\Id
17
     * @ORM\Column(type="integer")
18
     * @ORM\GeneratedValue(strategy="AUTO")
19
     */
20
    protected $id;
21
22
    /**
23
     * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Group")
24
     * @ORM\JoinTable(name="fos_user_user_group",
25
     *      joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
26
     *      inverseJoinColumns={@ORM\JoinColumn(name="group_id", referencedColumnName="id")}
27
     * )
28
     */
29
    protected $groups;
30
31
    /**
32
     * @ORM\OneToMany(targetEntity="Poll", mappedBy="creator")
33
     */
34
    private $createdPolls;
35
36
    /**
37
     * @ORM\Column(type="string")
38
     */
39
    protected $name;
40
41
    /**
42
     * @ORM\OneToMany(targetEntity="Vote", mappedBy="caster")
43
     */
44
    private $votes;
45
46
    /**
47
     * Constructor.
48
     */
49 1
    public function __construct()
50
    {
51 1
        parent::__construct();
52
53 1
        $this->createdPolls = new ArrayCollection();
54 1
        $this->votes = new ArrayCollection();
55 1
    }
56
57
    /**
58
     * Set name.
59
     *
60
     * @param string $name
61
     *
62
     * @return Poll
63
     */
64
    public function setName(string $name)
65
    {
66
        $this->name = $name;
67
68
        return $this;
69
    }
70
71
    /**
72
     * Get name.
73
     *
74
     * @return string
75
     */
76
    public function getName(): string
77
    {
78
        return $this->name;
79
    }
80
81
    /**
82
     * Add createdPoll.
83
     *
84
     * @param \AppBundle\Entity\Poll $createdPoll
85
     *
86
     * @return User
87
     */
88
    public function addCreatedPoll(\AppBundle\Entity\Poll $createdPoll)
89
    {
90
        $this->createdPolls[] = $createdPoll;
91
92
        return $this;
93
    }
94
95
    /**
96
     * Remove createdPoll.
97
     *
98
     * @param \AppBundle\Entity\Poll $createdPoll
99
     */
100
    public function removeCreatedPoll(\AppBundle\Entity\Poll $createdPoll)
101
    {
102
        $this->createdPolls->removeElement($createdPoll);
103
    }
104
105
    /**
106
     * Get createdPolls.
107
     *
108
     * @return \Doctrine\Common\Collections\Collection
109
     */
110
    public function getCreatedPolls()
111
    {
112
        return $this->createdPolls;
113
    }
114
115
    /**
116
     * Add vote.
117
     *
118
     * @param \AppBundle\Entity\Vote $vote
119
     *
120
     * @return User
121
     */
122
    public function addVote(\AppBundle\Entity\Vote $vote)
123
    {
124
        $this->votes[] = $vote;
125
126
        return $this;
127
    }
128
129
    /**
130
     * Remove vote.
131
     *
132
     * @param \AppBundle\Entity\Vote $vote
133
     */
134
    public function removeVote(\AppBundle\Entity\Vote $vote)
135
    {
136
        $this->votes->removeElement($vote);
137
    }
138
139
    /**
140
     * Get votes.
141
     *
142
     * @return \Doctrine\Common\Collections\Collection
143
     */
144
    public function getVotes()
145
    {
146
        return $this->votes;
147
    }
148
}
149