Unregistration   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 186
Duplicated Lines 6.99 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 14
lcom 0
cbo 1
dl 13
loc 186
rs 10
c 0
b 0
f 0

12 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 4 1
A getEmail() 0 4 1
A setEmail() 0 4 1
A getConfirmationKey() 0 4 1
A __toString() 13 13 3
A getSaturday() 0 4 1
A getSunday() 0 4 1
A setSaturday() 0 4 1
A setSunday() 0 4 1
A setConfirmed() 0 4 1
A setEvent() 0 4 1
A getCreated() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace BCRM\BackendBundle\Entity\Event;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Gedmo\Mapping\Annotation as Gedmo;
7
use LiteCQRS\Plugin\CRUD\AggregateResource;
8
use Symfony\Component\Validator\Constraints as Assert;
9
10
11
/**
12
 * Unregistration
13
 *
14
 * @ORM\Table(name="unregistration",indexes={@ORM\Index(name="email_idx", columns={"email"})})
15
 * @ORM\Entity(repositoryClass="BCRM\BackendBundle\Entity\Event\DoctrineUnregistrationRepository")
16
 */
17
class Unregistration extends AggregateResource
18
{
19
    /**
20
     * @var integer
21
     * @ORM\Column(name="id", type="integer")
22
     * @ORM\Id
23
     * @ORM\GeneratedValue(strategy="AUTO")
24
     */
25
    protected $id;
26
27
    /**
28
     * @Assert\NotBlank()
29
     * @ORM\ManyToOne(targetEntity="BCRM\BackendBundle\Entity\Event\Event", inversedBy="unregistrations")
30
     * @ORM\JoinColumn(name="event_id", referencedColumnName="id", nullable=false)
31
     * @var Event
32
     */
33
    protected $event;
34
35
    /**
36
     * @var string
37
     * @Assert\NotBlank()
38
     * @Assert\Email()
39
     * @ORM\Column(type="string")
40
     */
41
    protected $email;
42
43
    /**
44
     * @var boolean
45
     * @Assert\NotBlank()
46
     * @Assert\Type(type="boolean")
47
     * @ORM\Column(type="boolean")
48
     */
49
    protected $saturday = false;
50
51
    /**
52
     * @var boolean
53
     * @Assert\NotBlank()
54
     * @Assert\Type(type="boolean")
55
     * @ORM\Column(type="boolean")
56
     */
57
    protected $sunday = false;
58
59
    /**
60
     * @ORM\Column(type="string", nullable=true, name="confirmation_key")
61
     * @var string Login-Key
62
     */
63
    protected $confirmationKey;
64
65
    /**
66
     * @var boolean
67
     * @Assert\NotBlank()
68
     * @Assert\Type(type="boolean")
69
     * @ORM\Column(type="boolean")
70
     */
71
    protected $confirmed = false;
72
73
    /**
74
     * @var boolean
75
     * @Assert\NotBlank()
76
     * @Assert\Type(type="boolean")
77
     * @ORM\Column(type="boolean")
78
     */
79
    protected $processed = false;
80
81
    /**
82
     * @Gedmo\Timestampable(on="create")
83
     * @ORM\Column(type="datetime")
84
     * @var \DateTime
85
     */
86
    protected $created;
87
88
    /**
89
     * @Gedmo\Timestampable(on="update")
90
     * @ORM\Column(type="datetime", nullable=true)
91
     * @var \DateTime
92
     */
93
    protected $updated;
94
95
    /**
96
     * Get id
97
     *
98
     * @return integer
99
     */
100
    public function getId()
101
    {
102
        return $this->id;
103
    }
104
105
    /**
106
     * @return string
107
     */
108
    public function getEmail()
109
    {
110
        return $this->email;
111
    }
112
113
    /**
114
     * @param string $email
115
     */
116
    public function setEmail($email)
117
    {
118
        $this->email = strtolower($email);
119
    }
120
121
    /**
122
     * @return string
123
     */
124
    public function getConfirmationKey()
125
    {
126
        return $this->confirmationKey;
127
    }
128
129
    /**
130
     * @return string
131
     */
132 View Code Duplication
    public function __toString()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
133
    {
134
        $str  = $this->email;
135
        $days = array();
136
        if ($this->saturday) {
137
            $days[] = 'SA';
138
        }
139
        if ($this->sunday) {
140
            $days[] = 'SU';
141
        }
142
        $str .= ' (' . join('+', $days) . ')';
143
        return $str;
144
    }
145
146
    /**
147
     * @return boolean
148
     */
149
    public function getSaturday()
150
    {
151
        return $this->saturday;
152
    }
153
154
    /**
155
     * @param boolean $saturday
156
     */
157
    public function setSaturday($saturday)
158
    {
159
        $this->saturday = (bool)$saturday;
160
    }
161
162
    /**
163
     * @return boolean
164
     */
165
    public function getSunday()
166
    {
167
        return $this->sunday;
168
    }
169
170
    /**
171
     * @param boolean $sunday
172
     */
173
    public function setSunday($sunday)
174
    {
175
        $this->sunday = (bool)$sunday;
176
    }
177
178
    /**
179
     * @param boolean $confirmed
180
     */
181
    public function setConfirmed($confirmed)
182
    {
183
        $this->confirmed = (bool)$confirmed;
184
    }
185
186
    /**
187
     * @param \BCRM\BackendBundle\Entity\Event\Event $event
188
     */
189
    public function setEvent(Event $event)
190
    {
191
        $this->event = $event;
192
    }
193
194
    /**
195
     * @return \DateTime
196
     */
197
    public function getCreated()
198
    {
199
        return $this->created;
200
    }
201
202
}
203
204