Range::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.9
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Hop\Ranges;
6
7
final class Range
8
{
9
    /**
10
     * @var \DateTime
11
     */
12
    private $dateFrom;
13
14
    /**
15
     * @var \DateTime
16
     */
17
    private $dateTo;
18
19
    /**
20
     * Range constructor.
21
     * @param \DateTime $dateFrom
22
     * @param \DateTime $dateTo
23
     */
24 11
    public function __construct(
25
        \DateTime $dateFrom,
26
        \DateTime $dateTo
27
    ) {
28 11
        if ($dateTo < $dateFrom) {
29 1
            throw new \InvalidArgumentException('Date to must be greater than date from');
30
        }
31
32 10
        $this->dateFrom = $dateFrom;
33 10
        $this->dateTo = $dateTo;
34 10
    }
35
36
    /**
37
     * @return \DateTime
38
     */
39 10
    public function dateFrom(): \DateTime
40
    {
41 10
        return $this->dateFrom;
42
    }
43
44
    /**
45
     * @return \DateTime
46
     */
47 10
    public function dateTo(): \DateTime
48
    {
49 10
        return $this->dateTo;
50
    }
51
}
52