GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — user-entity ( d5799b...6b6569 )
by Luis Ramón
02:58
created

Calendar   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 197
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 17
c 2
b 0
f 0
lcom 1
cbo 2
dl 0
loc 197
rs 10

16 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
A getStartDate() 0 4 1
A setStartDate() 0 5 1
A getTotalHours() 0 4 1
A setTotalHours() 0 5 1
A getHoursMon() 0 4 1
A setHoursMon() 0 5 1
A getHoursTue() 0 4 1
A setHoursTue() 0 5 1
A getHoursWed() 0 4 1
A setHoursWed() 0 5 1
A getHoursThu() 0 4 1
A setHoursThu() 0 5 1
A getHoursFri() 0 4 1
A setHoursFri() 0 5 1
A validate() 0 10 2
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\Form\Model;
22
23
use Symfony\Component\Validator\Constraints as Assert;
24
use Symfony\Component\Validator\Context\ExecutionContextInterface;
25
26
class Calendar
27
{
28
    /**
29
     * @var \DateTime
30
     */
31
    protected $startDate;
32
33
    /**
34
     * @Assert\GreaterThanOrEqual(value="1")
35
     * @var float
36
     */
37
    protected $totalHours;
38
39
    /**
40
     * @Assert\Range(min="0", max="24")
41
     * @var float
42
     */
43
    protected $hoursMon;
44
45
    /**
46
     * @Assert\Range(min="0", max="24")
47
     * @var float
48
     */
49
    protected $hoursTue;
50
51
    /**
52
     * @Assert\Range(min="0", max="24")
53
     * @var float
54
     */
55
    protected $hoursWed;
56
57
    /**
58
     * @Assert\Range(min="0", max="24")
59
     * @var float
60
     */
61
    protected $hoursThu;
62
63
    /**
64
     * @Assert\Range(min="0", max="24")
65
     * @var float
66
     */
67
    protected $hoursFri;
68
69
    public function __construct($total = 0)
70
    {
71
        $this->startDate = new \DateTime();
72
73
        $this->totalHours = $total;
0 ignored issues
show
Documentation Bug introduced by
The property $totalHours was declared of type double, but $total is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
74
75
        $this->hoursMon = 0;
0 ignored issues
show
Documentation Bug introduced by
The property $hoursMon was declared of type double, but 0 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
76
        $this->hoursTue = 0;
0 ignored issues
show
Documentation Bug introduced by
The property $hoursTue was declared of type double, but 0 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
77
        $this->hoursWed = 0;
0 ignored issues
show
Documentation Bug introduced by
The property $hoursWed was declared of type double, but 0 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
78
        $this->hoursThu = 0;
0 ignored issues
show
Documentation Bug introduced by
The property $hoursThu was declared of type double, but 0 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
79
        $this->hoursFri = 0;
0 ignored issues
show
Documentation Bug introduced by
The property $hoursFri was declared of type double, but 0 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
80
    }
81
82
    /**
83
     * @return \DateTime
84
     */
85
    public function getStartDate()
86
    {
87
        return $this->startDate;
88
    }
89
90
    /**
91
     * @param \DateTime $startDate
92
     * @return Calendar
93
     */
94
    public function setStartDate($startDate)
95
    {
96
        $this->startDate = $startDate;
97
        return $this;
98
    }
99
100
    /**
101
     * @return int
102
     */
103
    public function getTotalHours()
104
    {
105
        return $this->totalHours;
106
    }
107
108
    /**
109
     * @param int $totalHours
110
     * @return Calendar
111
     */
112
    public function setTotalHours($totalHours)
113
    {
114
        $this->totalHours = $totalHours;
0 ignored issues
show
Documentation Bug introduced by
The property $totalHours was declared of type double, but $totalHours is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
115
        return $this;
116
    }
117
118
    /**
119
     * @return int
120
     */
121
    public function getHoursMon()
122
    {
123
        return $this->hoursMon;
124
    }
125
126
    /**
127
     * @param int $hoursMon
128
     * @return Calendar
129
     */
130
    public function setHoursMon($hoursMon)
131
    {
132
        $this->hoursMon = $hoursMon;
0 ignored issues
show
Documentation Bug introduced by
The property $hoursMon was declared of type double, but $hoursMon is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
133
        return $this;
134
    }
135
136
    /**
137
     * @return int
138
     */
139
    public function getHoursTue()
140
    {
141
        return $this->hoursTue;
142
    }
143
144
    /**
145
     * @param int $hoursTue
146
     * @return Calendar
147
     */
148
    public function setHoursTue($hoursTue)
149
    {
150
        $this->hoursTue = $hoursTue;
0 ignored issues
show
Documentation Bug introduced by
The property $hoursTue was declared of type double, but $hoursTue is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
151
        return $this;
152
    }
153
154
    /**
155
     * @return int
156
     */
157
    public function getHoursWed()
158
    {
159
        return $this->hoursWed;
160
    }
161
162
    /**
163
     * @param int $hoursWed
164
     * @return Calendar
165
     */
166
    public function setHoursWed($hoursWed)
167
    {
168
        $this->hoursWed = $hoursWed;
0 ignored issues
show
Documentation Bug introduced by
The property $hoursWed was declared of type double, but $hoursWed is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
169
        return $this;
170
    }
171
172
    /**
173
     * @return int
174
     */
175
    public function getHoursThu()
176
    {
177
        return $this->hoursThu;
178
    }
179
180
    /**
181
     * @param int $hoursThu
182
     * @return Calendar
183
     */
184
    public function setHoursThu($hoursThu)
185
    {
186
        $this->hoursThu = $hoursThu;
0 ignored issues
show
Documentation Bug introduced by
The property $hoursThu was declared of type double, but $hoursThu is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
187
        return $this;
188
    }
189
190
    /**
191
     * @return int
192
     */
193
    public function getHoursFri()
194
    {
195
        return $this->hoursFri;
196
    }
197
198
    /**
199
     * @param int $hoursFri
200
     * @return Calendar
201
     */
202
    public function setHoursFri($hoursFri)
203
    {
204
        $this->hoursFri = $hoursFri;
0 ignored issues
show
Documentation Bug introduced by
The property $hoursFri was declared of type double, but $hoursFri is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
205
        return $this;
206
    }
207
    
208
    /**
209
     * @Assert\Callback
210
     */
211
    public function validate(ExecutionContextInterface $context)
212
    {
213
        if ($this->getHoursMon() + $this->getHoursTue() + $this->getHoursWed()
214
            + $this->getHoursThu() + $this->getHoursFri() <= 0) {
215
        
216
            $context->buildViolation('calendar.no_hours')
217
                ->atPath('hoursMon')
218
                ->addViolation();
219
        }
220
    }
221
222
}
223