DayInWeek::sunday()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Adlogix\EventScheduler\TemporalExpression;
6
7
use Adlogix\EventScheduler\ValueObject\WeekDay;
8
use DateTimeInterface;
9
10
/**
11
 * @author Toni Van de Voorde <[email protected]>
12
 */
13
final class DayInWeek implements TemporalExpressionInterface
14
{
15
    /**
16
     * @var WeekDay
17
     */
18
    protected $day;
19
20
    /**
21
     * @param WeekDay $day
22
     */
23 2
    private function __construct(WeekDay $day)
24
    {
25 2
        $this->day = $day;
26 2
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31 2
    public function includes(DateTimeInterface $date): bool
32
    {
33 2
        return $this->day->equals(WeekDay::fromDateTime($date));
34
    }
35
36
    /**
37
     * @return DayInWeek
38
     */
39
    public static function monday(): self
40
    {
41
        return new self(WeekDay::monday());
42
    }
43
44
    /**
45
     * @return DayInWeek
46
     */
47
    public static function tuesday(): self
48
    {
49
        return new self(WeekDay::tuesday());
50
    }
51
52
    /**
53
     * @return DayInWeek
54
     */
55
    public static function wednesday(): self
56
    {
57
        return new self(WeekDay::wednesday());
58
    }
59
60
    /**
61
     * @return DayInWeek
62
     */
63
    public static function thursday(): self
64
    {
65
        return new self(WeekDay::thursday());
66
    }
67
68
    /**
69
     * @return DayInWeek
70
     */
71 1
    public static function friday(): self
72
    {
73 1
        return new self(WeekDay::friday());
74
    }
75
76
    /**
77
     * @return DayInWeek
78
     */
79
    public static function saturday(): self
80
    {
81
        return new self(WeekDay::saturday());
82
    }
83
84
    /**
85
     * @return DayInWeek
86
     */
87 1
    public static function sunday(): self
88
    {
89 1
        return new self(WeekDay::sunday());
90
    }
91
}
92