DateTimeAttribute   A
last analyzed

Complexity

Total Complexity 21

Size/Duplication

Total Lines 225
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

21 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A isAfter() 0 6 1
A isBefore() 0 6 1
A isBetween() 0 6 1
A isWeekend() 0 6 1
A isWeekday() 0 6 1
A isMonday() 0 6 1
A isTuesday() 0 6 1
A isWednesday() 0 6 1
A isThursday() 0 6 1
A isFriday() 0 6 1
A isSaturday() 0 6 1
A isSunday() 0 6 1
A isToday() 0 6 1
A isYesterday() 0 6 1
A isTomorrow() 0 6 1
A isLeapYear() 0 6 1
A isMorning() 0 6 1
A isAftenoon() 0 6 1
A isEvening() 0 6 1
A isNight() 0 6 1
1
<?php
2
/**
3
 * Author: Nil Portugués Calderó <[email protected]>
4
 * Date: 9/21/14
5
 * Time: 8:37 PM
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace NilPortugues\Validator\Attribute\DateTime;
12
13
use NilPortugues\Validator\Attribute\GenericAttribute;
14
use NilPortugues\Validator\Validator;
15
16
/**
17
 * Class DateTimeAttribute
18
 * @package NilPortugues\Validator\Attribute\DateTimeAttribute
19
 */
20
class DateTimeAttribute extends GenericAttribute
21
{
22
    /**
23
     * @param string    $propertyName
24
     * @param Validator $validator
25
     * @param array     $errorMessages
26
     * @param array     $functionMap
27
     */
28
    public function __construct($propertyName, Validator $validator, array &$errorMessages, array &$functionMap)
29
    {
30
        parent::__construct($propertyName, $validator, $errorMessages, $functionMap);
31
32
        $this->addCondition(__METHOD__);
33
    }
34
35
    /**
36
     * @param      $limit
37
     * @param bool $inclusive
38
     *
39
     * @return $this
40
     */
41
    public function isAfter($limit, $inclusive = false)
42
    {
43
        $this->addCondition(__METHOD__, [$limit, $inclusive]);
44
45
        return $this;
46
    }
47
48
    /**
49
     * @param      $limit
50
     * @param bool $inclusive
51
     *
52
     * @return $this
53
     */
54
    public function isBefore($limit, $inclusive = false)
55
    {
56
        $this->addCondition(__METHOD__, [$limit, $inclusive]);
57
58
        return $this;
59
    }
60
61
    /**
62
     * @param string $minDate
63
     * @param string $maxDate
64
     * @param bool   $inclusive
65
     *
66
     * @return $this
67
     */
68
    public function isBetween($minDate, $maxDate, $inclusive = false)
69
    {
70
        $this->addCondition(__METHOD__, [$minDate, $maxDate, $inclusive], ['min' => $minDate, 'max' => $maxDate]);
71
72
        return $this;
73
    }
74
75
    /*
76
     * @return $this
77
     */
78
    public function isWeekend()
79
    {
80
        $this->addCondition(__METHOD__);
81
82
        return $this;
83
    }
84
85
    /*
86
     * @return $this
87
     */
88
    public function isWeekday()
89
    {
90
        $this->addCondition(__METHOD__);
91
92
        return $this;
93
    }
94
95
    /*
96
     * @return $this
97
     */
98
    public function isMonday()
99
    {
100
        $this->addCondition(__METHOD__);
101
102
        return $this;
103
    }
104
105
    /*
106
     * @return $this
107
     */
108
    public function isTuesday()
109
    {
110
        $this->addCondition(__METHOD__);
111
112
        return $this;
113
    }
114
115
    /*
116
     * @return $this
117
     */
118
    public function isWednesday()
119
    {
120
        $this->addCondition(__METHOD__);
121
122
        return $this;
123
    }
124
125
    /*
126
     * @return $this
127
     */
128
    public function isThursday()
129
    {
130
        $this->addCondition(__METHOD__);
131
132
        return $this;
133
    }
134
135
    /*
136
     * @return $this
137
     */
138
    public function isFriday()
139
    {
140
        $this->addCondition(__METHOD__);
141
142
        return $this;
143
    }
144
145
    /*
146
     * @return $this
147
     */
148
    public function isSaturday()
149
    {
150
        $this->addCondition(__METHOD__);
151
152
        return $this;
153
    }
154
155
    /*
156
     * @return $this
157
     */
158
    public function isSunday()
159
    {
160
        $this->addCondition(__METHOD__);
161
162
        return $this;
163
    }
164
165
    /*
166
     * @return $this
167
     */
168
    public function isToday()
169
    {
170
        $this->addCondition(__METHOD__);
171
172
        return $this;
173
    }
174
175
    /*
176
     * @return $this
177
     */
178
    public function isYesterday()
179
    {
180
        $this->addCondition(__METHOD__);
181
182
        return $this;
183
    }
184
185
    /*
186
     * @return $this
187
     */
188
    public function isTomorrow()
189
    {
190
        $this->addCondition(__METHOD__);
191
192
        return $this;
193
    }
194
195
    /*
196
     * @return $this
197
     */
198
    public function isLeapYear()
199
    {
200
        $this->addCondition(__METHOD__);
201
202
        return $this;
203
    }
204
205
    /**
206
     * @return $this
207
     */
208
    public function isMorning()
209
    {
210
        $this->addCondition(__METHOD__);
211
212
        return $this;
213
    }
214
215
    /**
216
     * @return $this
217
     */
218
    public function isAftenoon()
219
    {
220
        $this->addCondition(__METHOD__);
221
222
        return $this;
223
    }
224
225
    /**
226
     * @return $this
227
     */
228
    public function isEvening()
229
    {
230
        $this->addCondition(__METHOD__);
231
232
        return $this;
233
    }
234
235
    /**
236
     * @return $this
237
     */
238
    public function isNight()
239
    {
240
        $this->addCondition(__METHOD__);
241
242
        return $this;
243
    }
244
}
245