Passed
Pull Request — master (#1)
by Jérémy
02:11
created

TimeIntervalDto::start()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace JDecool\Clockify\Model;
6
7
use DateTimeImmutable;
8
9
class TimeIntervalDto
10
{
11
    private $duration;
12
    private $end;
13
    private $start;
14
15
    public static function fromArray(array $data): self
16
    {
17
        return new self(
18
            new DateTimeImmutable($data['start']),
19
            new DateTimeImmutable($data['end']),
20
            $data['duration']
21
        );
22
    }
23
24
    public function __construct(
25
        DateTimeImmutable $start,
26
        DateTimeImmutable $end,
27
        string $duration
28
    ) {
29
        $this->duration = $duration;
30
        $this->start = $start;
31
        $this->end = $end;
32
    }
33
34
    public function duration(): string
35
    {
36
        return $this->duration;
37
    }
38
39
    public function end(): DateTimeImmutable
40
    {
41
        return $this->end;
42
    }
43
44
    public function start(): DateTimeImmutable
45
    {
46
        return $this->start;
47
    }
48
}
49