@@ 17-79 (lines=63) @@ | ||
14 | /** |
|
15 | * @author Tobias Nyholm <[email protected]> |
|
16 | */ |
|
17 | final class Stat implements CreatableFromArray |
|
18 | { |
|
19 | /** |
|
20 | * @var \DateTimeInterface |
|
21 | */ |
|
22 | private $start; |
|
23 | ||
24 | /** |
|
25 | * @var \DateTimeInterface |
|
26 | */ |
|
27 | private $end; |
|
28 | ||
29 | /** |
|
30 | * @var int |
|
31 | */ |
|
32 | private $count; |
|
33 | ||
34 | /** |
|
35 | * @param \DateTimeInterface $start |
|
36 | * @param \DateTimeInterface $end |
|
37 | * @param int $count |
|
38 | */ |
|
39 | private function __construct(\DateTimeInterface $start, \DateTimeInterface $end, int $count) |
|
40 | { |
|
41 | $this->start = $start; |
|
42 | $this->end = $end; |
|
43 | $this->count = $count; |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * @param array $data |
|
48 | * |
|
49 | * @return Stat |
|
50 | */ |
|
51 | public static function createFromArray(array $data): Stat |
|
52 | { |
|
53 | return new self(new \DateTimeImmutable($data['start']), new \DateTimeImmutable($data['end']), $data['count']); |
|
54 | } |
|
55 | ||
56 | /** |
|
57 | * @return \DateTimeInterface |
|
58 | */ |
|
59 | public function getStart(): \DateTimeInterface |
|
60 | { |
|
61 | return $this->start; |
|
62 | } |
|
63 | ||
64 | /** |
|
65 | * @return \DateTimeInterface |
|
66 | */ |
|
67 | public function getEnd(): \DateTimeInterface |
|
68 | { |
|
69 | return $this->end; |
|
70 | } |
|
71 | ||
72 | /** |
|
73 | * @return int |
|
74 | */ |
|
75 | public function getCount(): int |
|
76 | { |
|
77 | return $this->count; |
|
78 | } |
|
79 | } |
|
80 |
@@ 17-79 (lines=63) @@ | ||
14 | /** |
|
15 | * @author Tobias Nyholm <[email protected]> |
|
16 | */ |
|
17 | final class Total implements CreatableFromArray |
|
18 | { |
|
19 | /** |
|
20 | * @var \DateTimeInterface |
|
21 | */ |
|
22 | private $start; |
|
23 | ||
24 | /** |
|
25 | * @var \DateTimeInterface |
|
26 | */ |
|
27 | private $end; |
|
28 | ||
29 | /** |
|
30 | * @var int |
|
31 | */ |
|
32 | private $count; |
|
33 | ||
34 | /** |
|
35 | * @param \DateTimeInterface $start |
|
36 | * @param \DateTimeInterface $end |
|
37 | * @param int $count |
|
38 | */ |
|
39 | private function __construct(\DateTimeInterface $start, \DateTimeInterface $end, int $count) |
|
40 | { |
|
41 | $this->start = $start; |
|
42 | $this->end = $end; |
|
43 | $this->count = $count; |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * @param array $data |
|
48 | * |
|
49 | * @return Total |
|
50 | */ |
|
51 | public static function createFromArray(array $data): Total |
|
52 | { |
|
53 | return new self(new \DateTimeImmutable($data['start']), new \DateTimeImmutable($data['end']), $data['count']); |
|
54 | } |
|
55 | ||
56 | /** |
|
57 | * @return \DateTimeInterface |
|
58 | */ |
|
59 | public function getStart(): \DateTimeInterface |
|
60 | { |
|
61 | return $this->start; |
|
62 | } |
|
63 | ||
64 | /** |
|
65 | * @return \DateTimeInterface |
|
66 | */ |
|
67 | public function getEnd(): \DateTimeInterface |
|
68 | { |
|
69 | return $this->end; |
|
70 | } |
|
71 | ||
72 | /** |
|
73 | * @return int |
|
74 | */ |
|
75 | public function getCount(): int |
|
76 | { |
|
77 | return $this->count; |
|
78 | } |
|
79 | } |
|
80 |