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