Passed
Push — master ( d35dd0...09fa34 )
by Hector Luis
05:38
created

Period::extract()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 9
rs 10
c 0
b 0
f 0
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 DateInterval;
12
use DatePeriod;
13
use DateTime;
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 DateTime($from),
32
            new DateInterval('P1D'),
33
            new DateTime($to)
34
        );
35
    }
36
}
37