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

TimeIntervalDto   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A duration() 0 3 1
A end() 0 3 1
A fromArray() 0 6 1
A __construct() 0 8 1
A start() 0 3 1
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