PluginProbe
Booking Calendar / 11.6
Booking Calendar v11.6
11.9 11.8.4 11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 All 205 releases
booking / includes / booking-resource-selector / catalog / class-wpbc-booking-resource-dto.php

class-wpbc-booking-resource-dto.php in Booking Calendar 11.6, at includes/booking-resource-selector/catalog/class-wpbc-booking-resource-dto.php

65 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Public Booking Resource data-transfer object.
4 *
5 * @package Booking Calendar
6 * @since 11.6.0
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 /**
14 * Carry public Resource data between repositories and frontend presenters.
15 *
16 * The object intentionally excludes admin actions, capabilities, owner data,
17 * inspector schemas, and storage details. This keeps frontend renderers from
18 * becoming coupled to the Booking Resources administration table.
19 */
20 final class WPBC_Booking_Resource_DTO {
21
22 /**
23 * Normalized public Resource values.
24 *
25 * @var array<string,mixed>
26 */
27 private $values;
28
29 /**
30 * Initialize one immutable public Resource snapshot.
31 *
32 * @param array<string,mixed> $values Normalized public Resource values.
33 */
34 public function __construct( $values ) {
35 $defaults = array(
36 'resource_id' => 0,
37 'title' => '',
38 'description' => '',
39 'image_url' => '',
40 'attachment_id' => 0,
41 'parent_id' => 0,
42 'parent_title' => '',
43 'resource_type' => 'single',
44 'child_ids' => array(),
45 'child_count' => 0,
46 'capacity' => 1,
47 'count' => 0,
48 'availability_summary' => array(),
49 'price_summary' => array(),
50 );
51
52 $values = is_array( $values ) ? array_intersect_key( $values, $defaults ) : array();
53 $this->values = wp_parse_args( $values, $defaults );
54 }
55
56 /**
57 * Return the stable public representation used by frontend consumers.
58 *
59 * @return array<string,mixed> Public Resource values.
60 */
61 public function to_array() {
62 return $this->values;
63 }
64 }
65