Grupo::setTutores()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 0
cts 9
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 4
nop 1
crap 12
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
use Doctrine\Common\Collections\ArrayCollection;
24
use Doctrine\Common\Collections\Collection;
25
use Doctrine\ORM\Mapping as ORM;
26
27
28
/**
29
 * @ORM\Entity(repositoryClass="AppBundle\Entity\GrupoRepository")
30
 */
31
class Grupo
32
{
33
    /**
34
     * @ORM\Id
35
     * @ORM\Column(type="integer")
36
     * @ORM\GeneratedValue
37
     */
38
    protected $id;
39
    
40
    /**
41
     * @ORM\Column(type="string")
42
     * @var string
43
     */
44
    protected $descripcion;
45
46
    /**
47
     * @ORM\ManyToOne(targetEntity="Curso", inversedBy="grupos")
48
     * @ORM\JoinColumn(nullable=false)
49
     * @var Curso
50
     */
51
    protected $curso;
52
    
53
    /**
54
     * @ORM\OneToMany(targetEntity="Usuario", mappedBy="tutoria")
55
     * @var Collection
56
     */
57
    protected $tutores;
58
59
    /**
60
     * @ORM\OneToMany(targetEntity="Alumno", mappedBy="grupo")
61
     * @var Collection
62
     */
63
    protected $alumnado=null;
64
65
    public function __construct() {
66
        $this->tutores = new ArrayCollection();
67
        $this->alumnado = new ArrayCollection();
68
    }
69
    
70
    /**
71
     *
72
     * @return int
73
     */
74
    public function getId()
75
    {
76
        return $this->id;
77
    }
78
    
79
    /**
80
     *
81
     * @return string
82
     */
83
    public function getDescripcion()
84
    {
85
        return $this->descripcion;
86
    }
87
    
88
    /**
89
     *
90
     * @param string $valor
91
     * @return Grupo
92
     */
93
    public function setDescripcion($valor)
94
    {
95
        $this->descripcion = $valor;
96
97
        return $this;
98
    }
99
100
    /**
101
     *
102
     * @return string
103
     */
104
    public function __toString() {
105
        return $this->descripcion;
106
    }
107
108
    /**
109
     * Add alumnado
110
     *
111
     * @param Alumno $alumnado
112
     * @return Grupo
113
     */
114
    public function addAlumnado(Alumno $alumnado)
115
    {
116
        $this->alumnado[] = $alumnado;
117
        $alumnado->setGrupo($this);
118
119
        return $this;
120
    }
121
122
    /**
123
     * Remove alumnado
124
     *
125
     * @param Alumno $alumnado
126
     */
127
    public function removeAlumnado(Alumno $alumnado)
128
    {
129
        $this->alumnado->removeElement($alumnado);
130
        $alumnado->setGrupo(null);
131
    }
132
133
    /**
134
     * Get alumnado
135
     *
136
     * @return Collection
137
     */
138
    public function getAlumnado()
139
    {
140
        return $this->alumnado;
141
    }
142
143
    /**
144
     * Add tutores
145
     *
146
     * @param Usuario $tutores
147
     * @return Grupo
148
     */
149
    public function addTutore(Usuario $tutores)
150
    {
151
        $this->tutores[] = $tutores;
152
        $tutores->setTutoria($this);
153
154
        return $this;
155
    }
156
157
    /**
158
     * Remove tutores
159
     *
160
     * @param Usuario $tutor
161
     */
162
    public function removeTutore(Usuario $tutor)
163
    {
164
        $this->tutores->removeElement($tutor);
165
        $tutor->setTutoria(null);
166
    }
167
168
    /**
169
     * Get tutores
170
     *
171
     * @return Collection
172
     */
173
    public function getTutores()
174
    {
175
        return $this->tutores;
176
    }
177
178
    /**
179
     * Set tutores
180
     *
181
     * @param Collection $tutores
182
     * @return Grupo
183
     */
184
    public function setTutores($tutores)
185
    {
186
        dump($tutores);
187
        foreach($this->tutores as $tutor) {
188
            $tutor->setTutoria(null);
189
        }
190
        foreach($tutores as $tutor) {
191
            $tutor->setTutoria($this);
192
        }
193
        return $this;
194
    }
195
196
    /**
197
     * Set curso
198
     *
199
     * @param Curso $curso
200
     * @return Grupo
201
     */
202
    public function setCurso(Curso $curso = null)
203
    {
204
        $this->curso = $curso;
205
206
        return $this;
207
    }
208
209
    /**
210
     * Get curso
211
     *
212
     * @return Curso
213
     */
214
    public function getCurso()
215
    {
216
        return $this->curso;
217
    }
218
}
219