EventGroup   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 118
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 10
eloc 21
dl 0
loc 118
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 7 2
A addEvent() 0 6 1
A setEvents() 0 5 1
A getName() 0 3 1
A getId() 0 3 1
A setName() 0 5 1
A removeEvent() 0 6 1
A __construct() 0 3 1
A getEvents() 0 3 1
1
<?php
2
3
namespace Stfalcon\Bundle\EventBundle\Entity;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\ORM\Mapping as ORM;
7
use Symfony\Component\Validator\Constraints as Assert;
8
9
/**
10
 * Class EventGroup.
11
 *
12
 * @ORM\Table(name="event_group")
13
 * @ORM\Entity()
14
 */
15
class EventGroup
16
{
17
    /**
18
     * @var int
19
     *
20
     * @ORM\Column(name="id", type="integer")
21
     * @ORM\Id
22
     * @ORM\GeneratedValue(strategy="AUTO")
23
     */
24
    private $id;
25
26
    /**
27
     * @var string
28
     *
29
     * @ORM\Column(type="string", nullable=false)
30
     *
31
     * @Assert\NotNull()
32
     * @Assert\NotBlank()
33
     */
34
    private $name;
35
36
    /**
37
     * @ORM\OneToMany(targetEntity="Stfalcon\Bundle\EventBundle\Entity\Event", mappedBy="group", cascade={"remove", "persist"})
38
     */
39
    private $events;
40
41
    /**
42
     * EventGroup constructor.
43
     */
44
    public function __construct()
45
    {
46
        $this->events = new ArrayCollection();
47
    }
48
49
    /**
50
     * @return mixed
51
     */
52
    public function getId()
53
    {
54
        return $this->id;
55
    }
56
57
    /**
58
     * @return string
59
     */
60
    public function getName()
61
    {
62
        return $this->name;
63
    }
64
65
    /**
66
     * @param string $name
67
     *
68
     * @return $this
69
     */
70
    public function setName($name)
71
    {
72
        $this->name = $name;
73
74
        return $this;
75
    }
76
77
    /**
78
     * @return ArrayCollection $events
79
     */
80
    public function getEvents()
81
    {
82
        return $this->events;
83
    }
84
85
    /**
86
     * @param ArrayCollection $events
87
     *
88
     * @return $this
89
     */
90
    public function setEvents($events)
91
    {
92
        $this->events = $events;
93
94
        return $this;
95
    }
96
97
    /**
98
     * @param Event $event
99
     *
100
     * @return $this
101
     */
102
    public function addEvent($event)
103
    {
104
        $event->setGroup($this);
105
        $this->events[] = $event;
106
107
        return $this;
108
    }
109
110
    /**
111
     * @param Event $event
112
     *
113
     * @return $this
114
     */
115
    public function removeEvent($event)
116
    {
117
        $event->setGroup(null);
118
        $this->events->removeElement($event);
119
120
        return $this;
121
    }
122
123
    /**
124
     * @return string
125
     */
126
    public function __toString()
127
    {
128
        if ($this->id) {
129
            return $this->name;
130
        }
131
132
        return '';
133
    }
134
}
135