PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.29
Booktics – Appointment Booking Calendar for Service Businesses v1.0.29
1.0.29 1.0.28 1.0.27 1.0.26 1.0.25 1.0.24 1.0.23 1.0.22 1.0.21 1.0.20 1.0.19 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.2 1.0.3 All 31 releases
booktics / core / appointment / schedule / time-slot.php

time-slot.php in Booktics – Appointment Booking Calendar for Service Businesses 1.0.29, at core/appointment/schedule/time-slot.php

111 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 * Store maximum capacity
33 *
34 * @var int
35 */
36 public $max_capacity;
37
38 /**
39 * Store booked count
40 *
41 * @var int
42 */
43 public $booked_count;
44
45 /**
46 * Store available spots
47 *
48 * @var int
49 */
50 public $available_spots;
51
52 /**
53 * Team members who can take this slot.
54 *
55 * Only filled in when an extension merges several members' slots into one
56 * set, so it can remember who is behind a merged slot. Deliberately left
57 * out of to_array(): for a service that assigns automatically, which
58 * member is free is scheduling detail the customer does not need.
59 *
60 * Declared here rather than set dynamically, which PHP 8.2 deprecates and
61 * PHP 9 refuses.
62 *
63 * @var int[]
64 */
65 public $available_member_ids = [];
66
67 /**
68 * Constructor timeslot class
69 *
70 * @param string $start Start time for a time slot
71 * @param string $end End time for a time slot
72 * @param bool $is_available Status for time slot
73 * @param true
74 *
75 * @return void
76 */
77 public function __construct( string $start, string $end, bool $is_available = true, int $max_capacity = 1, int $available_spots = 1, int $booked_count = 0 ) {
78 $this->start = $start;
79 $this->end = $end;
80 $this->is_available = $is_available;
81 $this->max_capacity = $max_capacity;
82 $this->booked_count = $booked_count;
83 $this->available_spots = $available_spots;
84 }
85
86 /**
87 * Get time slot data as an array
88 *
89 * @return array Timeslot data
90 */
91 public function to_array(): array {
92 return [
93 'start' => $this->start,
94 'end' => $this->end,
95 'is_available' => $this->is_available,
96 'max_capacity' => $this->max_capacity,
97 'booked_count' => $this->booked_count,
98 'available_spots' => $this->available_spots,
99 ];
100 }
101
102 /**
103 * Specify data which should be serialized to JSON.
104 *
105 * @return array
106 */
107 public function jsonSerialize(): array {
108 return $this->to_array();
109 }
110 }
111