Conditions | 6 |
Paths | 4 |
Total Lines | 18 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 6 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
23 | public function __construct(array $excludedDays = []) |
||
24 | { |
||
25 | 1 | $excludedDays = array_unique($excludedDays); |
|
26 | |||
27 | 1 | sort($excludedDays); |
|
28 | |||
29 | 1 | if (count($excludedDays) >= 7) { |
|
30 | 1 | throw new \InvalidArgumentException('At least one day of the week must be allowed'); |
|
31 | } |
||
32 | |||
33 | 1 | foreach ($excludedDays as $excludedDay) { |
|
34 | 1 | $excludedDay = filter_var($excludedDay, FILTER_VALIDATE_INT); |
|
35 | |||
36 | 1 | if (!$excludedDay || $excludedDay < 1 || $excludedDay > 7) { |
|
37 | 1 | throw new \InvalidArgumentException('Exclude day must be an integer between 1 and 7'); |
|
38 | } |
||
39 | |||
40 | 1 | $this->excludedDays[] = $excludedDay; |
|
41 | } |
||
58 |