Parte   B
last analyzed

Complexity

Total Complexity 40

Size/Duplication

Total Lines 559
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 40
lcom 3
cbo 2
dl 0
loc 559
ccs 0
cts 98
cp 0
rs 8.2608
c 0
b 0
f 0

40 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getId() 0 4 1
A setAnotacion() 0 6 1
A getAnotacion() 0 4 1
A setActividades() 0 6 1
A getActividades() 0 4 1
A setFechaCreacion() 0 6 1
A getFechaCreacion() 0 4 1
A setFechaSuceso() 0 6 1
A getFechaSuceso() 0 4 1
A setFechaAviso() 0 6 1
A getFechaAviso() 0 4 1
A setUsuario() 0 6 1
A getUsuario() 0 4 1
A setAlumno() 0 6 1
A getAlumno() 0 4 1
A setSancion() 0 6 1
A getSancion() 0 4 1
A addObservacion() 0 6 1
A removeObservacion() 0 4 1
A getObservaciones() 0 4 1
A addAviso() 0 6 1
A removeAviso() 0 4 1
A getAvisos() 0 4 1
A setPrescrito() 0 6 1
A getPrescrito() 0 4 1
A setHayExpulsion() 0 6 1
A getHayExpulsion() 0 4 1
A setTramo() 0 6 1
A getTramo() 0 4 1
A addConducta() 0 6 1
A removeConducta() 0 4 1
A getConductas() 0 4 1
A __toString() 0 4 1
A setPrioritario() 0 6 1
A getPrioritario() 0 4 1
A setFechaRecordatorio() 0 6 1
A getFechaRecordatorio() 0 4 1
A setActividadesRealizadas() 0 6 1
A getActividadesRealizadas() 0 4 1

How to fix   Complexity   

Complex Class

Complex classes like Parte often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Parte, and based on these observations, apply Extract Interface, too.

1
<?php
2
/*
3
  GESTCONV - Aplicación web para la gestión de la convivencia en centros educativos
4
5
  Copyright (C) 2015: Luis Ramón López López
6
7
  This program is free software: you can redistribute it and/or modify
8
  it under the terms of the GNU Affero General Public License as published by
9
  the Free Software Foundation, either version 3 of the License, or
10
  (at your option) any later version.
11
12
  This program is distributed in the hope that it will be useful,
13
  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
  GNU Affero General Public License for more details.
16
17
  You should have received a copy of the GNU Affero General Public License
18
  along with this program.  If not, see [http://www.gnu.org/licenses/].
19
*/
20
21
namespace AppBundle\Entity;
22
23
24
use Doctrine\Common\Collections\ArrayCollection;
25
use Doctrine\Common\Collections\Collection;
26
use Doctrine\ORM\Mapping as ORM;
27
use Symfony\Component\Validator\Constraints as Assert;
28
use AppBundle\Validator\Constraints\DateRange as AssertDateRange;
29
30
31
/**
32
 * @ORM\Entity(repositoryClass="AppBundle\Entity\ParteRepository")
33
 */
34
class Parte
35
{
36
37
    /**
38
     * @ORM\Id
39
     * @ORM\Column(type="integer")
40
     * @ORM\GeneratedValue
41
     */
42
    protected $id;
43
    /**
44
     * @ORM\ManyToOne(targetEntity="Usuario", inversedBy="partes")
45
     * @ORM\JoinColumn(nullable=false)
46
     * @var Usuario
47
     *
48
     * @Assert\NotBlank()
49
     */
50
    protected $usuario;
51
    /**
52
     * @ORM\ManyToOne(targetEntity="Alumno", inversedBy="partes")
53
     * @ORM\JoinColumn(nullable=false)
54
     * @var Alumno
55
     */
56
    protected $alumno;
57
    /**
58
     * @ORM\Column(type="text", nullable=false)
59
     * @var string
60
     *
61
     * @Assert\NotBlank
62
     * @Assert\Length(min="10", minMessage="parte.anotacion.min_length")
63
     */
64
    protected $anotacion;
65
    /**
66
     * @ORM\Column(type="text", nullable=true)
67
     * @var string
68
     *
69
     * @Assert\NotBlank(groups={"expulsion"}, message="parte.actividades.expulsion")
70
     */
71
    protected $actividades;
72
    /**
73
     * @ORM\Column(type="datetime", nullable=false)
74
     * @var \DateTime
75
     */
76
    protected $fechaCreacion;
77
    /**
78
     * @ORM\Column(type="datetime", nullable=false)
79
     * @var \DateTime
80
     *
81
     * @Assert\NotBlank(groups={"nuevo"}, message="parte.fecha_suceso.not_blank")
82
     * @AssertDateRange(max="now +10 minute", maxMessage="parte.fecha_suceso.max")
83
     */
84
    protected $fechaSuceso;
85
    /**
86
     * @ORM\ManyToOne(targetEntity="TramoParte")
87
     * @ORM\JoinColumn(nullable=false)
88
     * @var TramoParte
89
     *
90
     * @Assert\NotBlank(groups={"nuevo"}, message="parte.tramo.not_blank")
91
     */
92
    protected $tramo;
93
    /**
94
     * @ORM\Column(type="datetime", nullable=true)
95
     * @var \DateTime
96
     */
97
    protected $fechaAviso;
98
    /**
99
     * @ORM\Column(type="datetime", nullable=true)
100
     * @var \DateTime
101
     */
102
    protected $fechaRecordatorio;
103
    /**
104
     * @ORM\Column(type="boolean", nullable=false)
105
     * @var boolean
106
     */
107
    protected $prescrito;
108
    /**
109
     * @ORM\Column(type="boolean", nullable=false)
110
     * @var boolean
111
     */
112
    protected $prioritario;
113
    /**
114
     * @ORM\Column(type="boolean", nullable=false)
115
     * @var boolean
116
     */
117
    protected $hayExpulsion;
118
    /**
119
     * @ORM\Column(type="boolean", nullable=true)
120
     * @var boolean
121
     */
122
    protected $actividadesRealizadas;
123
    /**
124
     * @ORM\ManyToMany(targetEntity="TipoConducta")
125
     * @var Collection
126
     *
127
     * @Assert\Count(min="1", minMessage="parte.conductas.min")
128
     */
129
    protected $conductas = null;
130
    /**
131
     * @ORM\ManyToOne(targetEntity="Sancion", inversedBy="partes")
132
     * @var Sancion
133
     */
134
    protected $sancion;
135
    /**
136
     * @ORM\OneToMany(targetEntity="ObservacionParte", mappedBy="parte")
137
     * @var Collection
138
     */
139
    protected $observaciones = null;
140
    /**
141
     * @ORM\OneToMany(targetEntity="AvisoParte", mappedBy="parte")
142
     * @var Collection
143
     */
144
    protected $avisos = null;
145
146
    /**
147
     * Constructor
148
     */
149
    public function __construct()
150
    {
151
        $this->conductas = new ArrayCollection();
152
        $this->observaciones = new ArrayCollection();
153
        $this->avisos = new ArrayCollection();
154
    }
155
156
    /**
157
     * Get id
158
     *
159
     * @return integer 
160
     */
161
    public function getId()
162
    {
163
        return $this->id;
164
    }
165
166
    /**
167
     * Set anotacion
168
     *
169
     * @param string $anotacion
170
     * @return Parte
171
     */
172
    public function setAnotacion($anotacion)
173
    {
174
        $this->anotacion = $anotacion;
175
176
        return $this;
177
    }
178
179
    /**
180
     * Get anotacion
181
     *
182
     * @return string 
183
     */
184
    public function getAnotacion()
185
    {
186
        return $this->anotacion;
187
    }
188
189
    /**
190
     * Set actividades
191
     *
192
     * @param string $actividades
193
     * @return Parte
194
     */
195
    public function setActividades($actividades)
196
    {
197
        $this->actividades = $actividades;
198
199
        return $this;
200
    }
201
202
    /**
203
     * Get actividades
204
     *
205
     * @return string 
206
     */
207
    public function getActividades()
208
    {
209
        return $this->actividades;
210
    }
211
212
    /**
213
     * Set fechaCreacion
214
     *
215
     * @param \DateTime $fechaCreacion
216
     * @return Parte
217
     */
218
    public function setFechaCreacion($fechaCreacion)
219
    {
220
        $this->fechaCreacion = $fechaCreacion;
221
222
        return $this;
223
    }
224
225
    /**
226
     * Get fechaCreacion
227
     *
228
     * @return \DateTime 
229
     */
230
    public function getFechaCreacion()
231
    {
232
        return $this->fechaCreacion;
233
    }
234
235
    /**
236
     * Set fechaSuceso
237
     *
238
     * @param \DateTime $fechaSuceso
239
     * @return Parte
240
     */
241
    public function setFechaSuceso($fechaSuceso)
242
    {
243
        $this->fechaSuceso = $fechaSuceso;
244
245
        return $this;
246
    }
247
248
    /**
249
     * Get fechaSuceso
250
     *
251
     * @return \DateTime
252
     */
253
    public function getFechaSuceso()
254
    {
255
        return $this->fechaSuceso;
256
    }
257
258
    /**
259
     * Set fechaAviso
260
     *
261
     * @param \DateTime $fechaAviso
262
     * @return Parte
263
     */
264
    public function setFechaAviso($fechaAviso)
265
    {
266
        $this->fechaAviso = $fechaAviso;
267
268
        return $this;
269
    }
270
271
    /**
272
     * Get fechaAviso
273
     *
274
     * @return \DateTime 
275
     */
276
    public function getFechaAviso()
277
    {
278
        return $this->fechaAviso;
279
    }
280
281
    /**
282
     * Set usuario
283
     *
284
     * @param Usuario $usuario
285
     * @return Parte
286
     */
287
    public function setUsuario(Usuario $usuario = null)
288
    {
289
        $this->usuario = $usuario;
290
291
        return $this;
292
    }
293
294
    /**
295
     * Get usuario
296
     *
297
     * @return Usuario
298
     */
299
    public function getUsuario()
300
    {
301
        return $this->usuario;
302
    }
303
304
    /**
305
     * Set alumno
306
     *
307
     * @param Alumno $alumno
308
     * @return Parte
309
     */
310
    public function setAlumno(Alumno $alumno = null)
311
    {
312
        $this->alumno = $alumno;
313
314
        return $this;
315
    }
316
317
    /**
318
     * Get alumno
319
     *
320
     * @return Alumno
321
     */
322
    public function getAlumno()
323
    {
324
        return $this->alumno;
325
    }
326
327
    /**
328
     * Set sancion
329
     *
330
     * @param Sancion $sancion
331
     * @return Parte
332
     */
333
    public function setSancion(Sancion $sancion = null)
334
    {
335
        $this->sancion = $sancion;
336
337
        return $this;
338
    }
339
340
    /**
341
     * Get sancion
342
     *
343
     * @return Sancion
344
     */
345
    public function getSancion()
346
    {
347
        return $this->sancion;
348
    }
349
350
    /**
351
     * Add observaciones
352
     *
353
     * @param ObservacionParte $observaciones
354
     * @return Parte
355
     */
356
    public function addObservacion(ObservacionParte $observaciones)
357
    {
358
        $this->observaciones[] = $observaciones;
359
360
        return $this;
361
    }
362
363
    /**
364
     * Remove observaciones
365
     *
366
     * @param ObservacionParte $observaciones
367
     */
368
    public function removeObservacion(ObservacionParte $observaciones)
369
    {
370
        $this->observaciones->removeElement($observaciones);
371
    }
372
373
    /**
374
     * Get observaciones
375
     *
376
     * @return Collection
377
     */
378
    public function getObservaciones()
379
    {
380
        return $this->observaciones;
381
    }
382
383
    /**
384
     * Add avisos
385
     *
386
     * @param AvisoParte $avisos
387
     * @return Parte
388
     */
389
    public function addAviso(AvisoParte $avisos)
390
    {
391
        $this->avisos[] = $avisos;
392
393
        return $this;
394
    }
395
396
    /**
397
     * Remove avisos
398
     *
399
     * @param AvisoParte $avisos
400
     */
401
    public function removeAviso(AvisoParte $avisos)
402
    {
403
        $this->avisos->removeElement($avisos);
404
    }
405
406
    /**
407
     * Get avisos
408
     *
409
     * @return Collection
410
     */
411
    public function getAvisos()
412
    {
413
        return $this->avisos;
414
    }
415
416
    /**
417
     * Set prescrito
418
     *
419
     * @param boolean $prescrito
420
     * @return Parte
421
     */
422
    public function setPrescrito($prescrito)
423
    {
424
        $this->prescrito = $prescrito;
425
426
        return $this;
427
    }
428
429
    /**
430
     * Get prescrito
431
     *
432
     * @return boolean 
433
     */
434
    public function getPrescrito()
435
    {
436
        return $this->prescrito;
437
    }
438
439
    /**
440
     * Set prioritario
441
     *
442
     * @param boolean $prioritario
443
     * @return Parte
444
     */
445
    public function setPrioritario($prioritario)
446
    {
447
        $this->prioritario = $prioritario;
448
449
        return $this;
450
    }
451
452
    /**
453
     * Get prioritario
454
     *
455
     * @return boolean
456
     */
457
    public function getPrioritario()
458
    {
459
        return $this->prioritario;
460
    }
461
462
    /**
463
     * Set fechaRecordatorio
464
     *
465
     * @param \DateTime $fechaRecordatorio
466
     * @return Parte
467
     */
468
    public function setFechaRecordatorio($fechaRecordatorio)
469
    {
470
        $this->fechaRecordatorio = $fechaRecordatorio;
471
472
        return $this;
473
    }
474
475
    /**
476
     * Get fechaRecordatorio
477
     *
478
     * @return \DateTime
479
     */
480
    public function getFechaRecordatorio()
481
    {
482
        return $this->fechaRecordatorio;
483
    }
484
485
    /**
486
     * Set hayExpulsion
487
     *
488
     * @param boolean $hayExpulsion
489
     * @return Parte
490
     */
491
    public function setHayExpulsion($hayExpulsion)
492
    {
493
        $this->hayExpulsion = $hayExpulsion;
494
495
        return $this;
496
    }
497
498
    /**
499
     * Get hayExpulsion
500
     *
501
     * @return boolean
502
     */
503
    public function getHayExpulsion()
504
    {
505
        return $this->hayExpulsion;
506
    }
507
508
    /**
509
     * Set actividadesRealizadas
510
     *
511
     * @param boolean $actividadesRealizadas
512
     * @return Parte
513
     */
514
    public function setActividadesRealizadas($actividadesRealizadas)
515
    {
516
        $this->actividadesRealizadas = $actividadesRealizadas;
517
518
        return $this;
519
    }
520
521
    /**
522
     * Get actividadesRealizadas
523
     *
524
     * @return boolean
525
     */
526
    public function getActividadesRealizadas()
527
    {
528
        return $this->actividadesRealizadas;
529
    }
530
531
    /**
532
     * Set tramo
533
     *
534
     * @param TramoParte $tramo
535
     * @return Parte
536
     */
537
    public function setTramo(TramoParte $tramo = null)
538
    {
539
        $this->tramo = $tramo;
540
541
        return $this;
542
    }
543
544
    /**
545
     * Get tramo
546
     *
547
     * @return TramoParte
548
     */
549
    public function getTramo()
550
    {
551
        return $this->tramo;
552
    }
553
554
    /**
555
     * Add conductas
556
     *
557
     * @param TipoConducta $conductas
558
     * @return Parte
559
     */
560
    public function addConducta(TipoConducta $conductas)
561
    {
562
        $this->conductas[] = $conductas;
563
564
        return $this;
565
    }
566
567
    /**
568
     * Remove conductas
569
     *
570
     * @param TipoConducta $conductas
571
     */
572
    public function removeConducta(TipoConducta $conductas)
573
    {
574
        $this->conductas->removeElement($conductas);
575
    }
576
577
    /**
578
     * Get conductas
579
     *
580
     * @return Collection
581
     */
582
    public function getConductas()
583
    {
584
        return $this->conductas;
585
    }
586
587
    public function __toString()
588
    {
589
        return $this->getId() . ' - ' . $this->alumno . ' - ' . $this->getAnotacion();
590
    }
591
592
}
593