Completed
Push — master ( 633079...840c2c )
by Frederick
11s
created

DateChecker   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 16
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A validateDateRange() 0 14 4
1
<?php
2
3
namespace Vanbrabantf\NpmStatFetcher\Helpers;
4
5
6
use Cake\Chronos\Chronos;
7
use DateTimeInterface;
8
use Vanbrabantf\NpmStatFetcher\Exceptions\DateException;
9
10
class DateChecker
11
{
12
    public static function validateDateRange(DateTimeInterface $start, DateTimeInterface $end)
13
    {
14
        $start = new Chronos($start);
0 ignored issues
show
Bug introduced by
$start of type DateTimeInterface is incompatible with the type null|string expected by parameter $time of Cake\Chronos\Chronos::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

14
        $start = new Chronos(/** @scrutinizer ignore-type */ $start);
Loading history...
15
        $end = new Chronos($end);
16
17
        if (
18
            $start->isFuture() ||
19
            $end->isFuture() ||
20
            $start > $end
21
        ) {
22
            throw new DateException('Date range is incorrect');
23
        }
24
25
        return true;
26
    }
27
}
28