| 1 | <?php |
||
| 10 | class DateTimeInterval implements \JsonSerializable |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * The start date and time. |
||
| 14 | * |
||
| 15 | * @var \DateTime |
||
| 16 | */ |
||
| 17 | private $start; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * The end date and time. |
||
| 21 | * |
||
| 22 | * @var \DateTime |
||
| 23 | */ |
||
| 24 | private $end; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Creates a date and time interval. |
||
| 28 | * |
||
| 29 | * @param \DateTime $start The starting date and time. |
||
| 30 | * @param \DateTime $end The ending date and time. |
||
| 31 | 51 | * @throws \InvalidArgumentException If the opening date and time is not earlier than closing date and time. |
|
| 32 | */ |
||
| 33 | 51 | public function __construct(\DateTime $start, \DateTime $end) |
|
| 48 | |||
| 49 | /** |
||
| 50 | * Get the start date and time. |
||
| 51 | * |
||
| 52 | 27 | * @return \DateTime |
|
| 53 | */ |
||
| 54 | 27 | public function getStart(): \DateTime |
|
| 58 | |||
| 59 | /** |
||
| 60 | * Get the end date and time. |
||
| 61 | * |
||
| 62 | 27 | * @return \DateTime |
|
| 63 | */ |
||
| 64 | 27 | public function getEnd(): \DateTime |
|
| 68 | |||
| 69 | /** |
||
| 70 | 3 | * {@inheritdoc} |
|
| 71 | */ |
||
| 72 | public function jsonSerialize() |
||
| 79 | } |
||
| 80 |