Period   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 24
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 4 1
A __construct() 0 10 2
1
<?php
2
3
namespace SchulzeFelix\SearchConsole;
4
5
use Carbon\Carbon;
6
use SchulzeFelix\SearchConsole\Exceptions\InvalidPeriod;
7
8
class Period
9
{
10
    /** @var Carbon */
11
    public $startDate;
12
13
    /** @var Carbon */
14
    public $endDate;
15
16
    public static function create(Carbon $startDate, Carbon $endDate): self
17
    {
18
        return new static($startDate, $endDate);
19
    }
20
21
    public function __construct(Carbon $startDate, Carbon $endDate)
22
    {
23
        if ($startDate > $endDate) {
24
            throw InvalidPeriod::startDateCannotBeAfterEndDate($startDate, $endDate);
25
        }
26
27
        $this->startDate = $startDate;
28
29
        $this->endDate = $endDate;
30
    }
31
}
32