Trimester   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 15.38%

Importance

Changes 0
Metric Value
dl 0
loc 53
ccs 2
cts 13
cp 0.1538
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A includes() 0 3 1
A third() 0 3 1
A __construct() 0 3 1
A fourth() 0 3 1
A first() 0 3 1
A second() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Adlogix\EventScheduler\TemporalExpression;
6
7
use Adlogix\EventScheduler\ValueObject\Trimester as TrimesterValueObject;
8
use DateTimeInterface;
9
10
/**
11
 * @author Toni Van de Voorde <[email protected]>
12
 */
13
final class Trimester implements TemporalExpressionInterface
14
{
15
    /**
16
     * @var TrimesterValueObject
17
     */
18
    protected $trimester;
19
20
    /**
21
     * @param TrimesterValueObject $trimester
22
     */
23
    public function __construct(TrimesterValueObject $trimester)
24
    {
25
        $this->trimester = $trimester;
26
    }
27
28
    /**
29
     * @return Trimester
30
     */
31
    public static function first(): self
32
    {
33
        return new self(TrimesterValueObject::first());
34
    }
35
36
    /**
37
     * @return Trimester
38
     */
39
    public static function second(): self
40
    {
41
        return new self(TrimesterValueObject::second());
42
    }
43
44
    /**
45
     * @return Trimester
46
     */
47
    public static function third(): self
48
    {
49
        return new self(TrimesterValueObject::third());
50
    }
51
52
    /**
53
     * @return Trimester
54
     */
55
    public static function fourth(): self
56
    {
57
        return new self(TrimesterValueObject::fourth());
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63 16
    public function includes(DateTimeInterface $date): bool
64
    {
65 16
        return $this->trimester->equals(TrimesterValueObject::fromNDateTime($date));
66
    }
67
}
68