Period   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 14
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A extract() 0 9 1
1
<?php
2
declare(strict_types=1);
3
/**
4
 * Domain Policy Class
5
 * @package Ticaje_BookingApi
6
 * @author  Hector Luis Barrientos <[email protected]>
7
 */
8
9
namespace Ticaje\BookingApi\Domain\Policies\Calendar\Disabling\Constraint;
10
11
use DatePeriod;
12
use DateInterval;
13
use DateTimeImmutable;
14
use Ticaje\BookingApi\Domain\Signatures\PeriodSignature;
15
16
/**
17
 * Class Period
18
 * @package Ticaje\BookingApi\Domain\Policies\Calendar\Disabling\Constraint
19
 */
20
class Period implements PeriodSignature
21
{
22
    /**
23
     * @inheritDoc
24
     */
25
    public function extract(array $data): DatePeriod
26
    {
27
        $from = $data['from'];
28
        $to = $data['to'];
29
30
        return new DatePeriod(
31
            new DateTimeImmutable($from),
32
            new DateInterval('P1D'),
33
            new DateTimeImmutable($to)
34
        );
35
    }
36
}