SchedulableEvent::temporalExpression()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Adlogix\EventScheduler;
6
7
use Adlogix\EventScheduler\TemporalExpression\TemporalExpressionInterface;
8
use DateTimeInterface;
9
10
/**
11
 * @author Toni Van de Voorde <[email protected]>
12
 */
13
final class SchedulableEvent implements Occurrable
14
{
15
    /**
16
     * @var EventInterface
17
     */
18
    protected $event;
19
20
    /**
21
     * @var TemporalExpressionInterface
22
     */
23
    protected $temporalExpression;
24
25
    /**
26
     * @param EventInterface              $event
27
     * @param TemporalExpressionInterface $temporalExpression
28
     */
29 13
    public function __construct(EventInterface $event, TemporalExpressionInterface $temporalExpression)
30
    {
31 13
        $this->event = $event;
32 13
        $this->temporalExpression = $temporalExpression;
33 13
    }
34
35
    /**
36
     * @return EventInterface
37
     */
38 7
    public function event(): EventInterface
39
    {
40 7
        return $this->event;
41
    }
42
43
    /**
44
     * @return TemporalExpressionInterface
45
     */
46
    public function temporalExpression(): TemporalExpressionInterface
47
    {
48
        return $this->temporalExpression;
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54 11
    public function isOccurring(EventInterface $event, DateTimeInterface $date): bool
55
    {
56 11
        return $this->event->equals($event) && $this->temporalExpression->includes($date);
57
    }
58
}
59