Passed
Push — master ( 0dc1ce...f4154d )
by Brian
12:26
created

WeekDaysProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 12
dl 0
loc 22
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 20 3
1
<?php
2
3
namespace Bmatovu\Ussd\Providers;
4
5
use Carbon\Carbon;
6
7
/**
8
 * Usage: Show the next 5 week days.
9
 *
10
 * ```xml
11
 * <list header="Choose appointment day" provider="week_days" prefix="appointment_date"/>
12
 * <variable name="appointment_date" value="{{appointment_date_id}}" />
13
 * ```
14
 */
15
class WeekDaysProvider extends BaseProvider
16
{
17
    public function load(): array
18
    {
19
        $day = Carbon::now();
20
21
        $weekDays = [];
22
23
        do {
24
            $day->addDay();
25
26
            if ($day->isWeekend()) {
27
                continue;
28
            }
29
30
            $weekDays[] = [
31
                'id' => $day->format('Y-m-d'),
32
                'label' => $day->format('D, jS M'),
33
            ];
34
        } while (count($weekDays) < 5);
35
36
        return $weekDays;
37
    }
38
}
39