| 1 |
<?php |
| 2 |
namespace Booktics\Appointment\Schedule; |
| 3 |
|
| 4 |
use JsonSerializable; |
| 5 |
|
| 6 |
/** |
| 7 |
* Timeslot class |
| 8 |
*/ |
| 9 |
class Time_Slot implements JsonSerializable { |
| 10 |
/** |
| 11 |
* Store start time |
| 12 |
* |
| 13 |
* @var string |
| 14 |
*/ |
| 15 |
public $start; |
| 16 |
|
| 17 |
/** |
| 18 |
* Store end time |
| 19 |
* |
| 20 |
* @var string |
| 21 |
*/ |
| 22 |
public $end; |
| 23 |
|
| 24 |
/** |
| 25 |
* Store time slot status |
| 26 |
* |
| 27 |
* @var bool |
| 28 |
*/ |
| 29 |
public $is_available; |
| 30 |
|
| 31 |
/** |
| 32 |
* Constructor timeslot class |
| 33 |
* |
| 34 |
* @param string $start Start time for a time slot |
| 35 |
* @param string $end End time for a time slot |
| 36 |
* @param bool $is_available Status for time slot |
| 37 |
* @param true |
| 38 |
* |
| 39 |
* @return void |
| 40 |
*/ |
| 41 |
public function __construct( string $start, string $end, bool $is_available = true ) { |
| 42 |
$this->start = $start; |
| 43 |
$this->end = $end; |
| 44 |
$this->is_available = $is_available; |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Get time slot data as an array |
| 49 |
* |
| 50 |
* @return array Timeslot data |
| 51 |
*/ |
| 52 |
public function to_array(): array { |
| 53 |
return [ |
| 54 |
'start' => $this->start, |
| 55 |
'end' => $this->end, |
| 56 |
'is_available' => $this->is_available, |
| 57 |
]; |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Specify data which should be serialized to JSON. |
| 62 |
* |
| 63 |
* @return array |
| 64 |
*/ |
| 65 |
public function jsonSerialize(): array { |
| 66 |
return $this->to_array(); |
| 67 |
} |
| 68 |
} |
| 69 |
|