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.

Day   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 43
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A days() 0 12 1
A mapDays() 0 4 1
A isValid() 0 4 1
A onDateTime() 0 4 1
A toISO() 0 4 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