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 — master ( f12cf1...80426b )
by Sebastian
02:42
created

Day::toISO()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Spatie\OpeningHours;
4
5
use DateTimeInterface;
6
use Spatie\OpeningHours\Helpers\Arr;
7
8
class Day
9
{
10
    const MONDAY = 'monday';
11
    const TUESDAY = 'tuesday';
12
    const WEDNESDAY = 'wednesday';
13
    const THURSDAY = 'thursday';
14
    const FRIDAY = 'friday';
15
    const SATURDAY = 'saturday';
16
    const SUNDAY = 'sunday';
17
18
    public static function days(): array
19
    {
20
        return [
21
            static::MONDAY,
22
            static::TUESDAY,
23
            static::WEDNESDAY,
24
            static::THURSDAY,
25
            static::FRIDAY,
26
            static::SATURDAY,
27
            static::SUNDAY,
28
        ];
29
    }
30
31
    public static function mapDays(callable $callback): array
32
    {
33
        return Arr::map(Arr::mirror(static::days()), $callback);
34
    }
35
36
    public static function isValid(string $day): bool
37
    {
38
        return in_array($day, static::days());
39
    }
40
41
    public static function onDateTime(DateTimeInterface $dateTime): string
42
    {
43
        return static::days()[$dateTime->format('N') - 1];
44
    }
45
46
    public static function toISO(string $day): int
47
    {
48
        return array_search($day, static::days()) + 1;
49
    }
50
}
51