PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / 1.5.21
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution v1.5.21
2.4.0 2.3.0 2.2.5 2.2.0 2.1.2 2.1.1 trunk 1.10.0 1.10.01 1.10.02 1.5.0 1.5.01 1.5.02 1.5.1 1.5.10 1.5.20 1.5.21 1.5.22 1.5.23 1.5.24 1.5.25 1.6.0 1.7.0 1.7.1 1.7.2 All 33 releases
fluent-booking / vendor / wpfluent / framework / src / WPFluent / Support / StdObject.php

StdObject.php in Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution 1.5.21, at vendor/wpfluent/framework/src/WPFluent/Support/StdObject.php

51 lines 963 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentBooking\Framework\Support;
4
5 use stdClass;
6
7 class StdObject
8 {
9 /**
10 * Creates an stdClass from an array
11 *
12 * @param array $array
13 * @return stdClass
14 */
15 public static function create(array $array)
16 {
17 $object = new stdClass;
18
19 foreach ($array as $key => $value) {
20 if (is_array($value)) {
21 $object->{$key} = call_user_func(__METHOD__, $value);
22 } else {
23 $object->{$key} = $value;
24 }
25 }
26
27 return $object;
28 }
29
30 /**
31 * Transforms an stdClass to array
32 *
33 * @param stdClass $object
34 * @return array
35 */
36 public static function toArray($object)
37 {
38 $array = [];
39
40 foreach ($object as $key => $value) {
41 if ($value instanceof stdClass) {
42 $array[$key] = call_user_func(__METHOD__, $value);
43 } else {
44 $array[$key] = $value;
45 }
46 }
47
48 return $array;
49 }
50 }
51