blob: 4e8cb9e97bdb8ddafa70dec5666b308d79e06c09 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
<?php
// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
namespace Icinga\Module\Reporting;
use Icinga\Module\Reporting\Model;
class Timeframe
{
/** @var int */
protected $id;
/** @var string */
protected $name;
/** @var string */
protected $title;
/** @var string */
protected $start;
/** @var string */
protected $end;
/**
* Create timeframe from the given model
*
* @param Model\Timeframe $timeframeModel
*
* @return static
*/
public static function fromModel(Model\Timeframe $timeframeModel): self
{
$timeframe = new static();
$timeframe->id = $timeframeModel->id;
$timeframe->name = $timeframeModel->name;
$timeframe->title = $timeframeModel->title;
$timeframe->start = $timeframeModel->start;
$timeframe->end = $timeframeModel->end;
return $timeframe;
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @return string
*/
public function getStart()
{
return $this->start;
}
/**
* @return string
*/
public function getEnd()
{
return $this->end;
}
public function getTimerange()
{
$start = new \DateTime($this->getStart());
$end = new \DateTime($this->getEnd());
return new Timerange($start, $end);
}
}
|