PluginProbe
UpStream: a Project Management Plugin for WordPress / 1.39.2
UpStream: a Project Management Plugin for WordPress v1.39.2
trunk 1.39.0 1.39.1 1.39.2 1.39.3 2.0.7 2.1.0
upstream / includes / abs-class-up-struct.php

abs-class-up-struct.php in UpStream: a Project Management Plugin for WordPress 1.39.2, at includes/abs-class-up-struct.php

56 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace UpStream;
4
5 /**
6 * Basic abstract class to represent a simple struct structure.
7 *
8 * @since 1.13.0
9 * @abstract
10 */
11 abstract class Struct
12 {
13 /**
14 * Prevent non existent properties from being retrieved.
15 *
16 * @since 1.13.0
17 *
18 * @param string $property Property being retrieved.
19 *
20 * @throws \RuntimeException
21 */
22 public function __get($property)
23 {
24 throw new \RuntimeException(sprintf('Trying to get non-existing property "%s".', $property));
25 }
26
27 /**
28 * Prevent non existent properties from being set.
29 *
30 * @since 1.13.0
31 *
32 * @param string $property Property being set.
33 * @param mixed $value Value being set.
34 *
35 * @throws \RuntimeException
36 */
37 public function __set($property, $value)
38 {
39 throw new \RuntimeException(sprintf('Trying to set non-existing property "%s".', $property));
40 }
41
42 /**
43 * Prevent structs from being passed by reference.
44 *
45 * @since 1.13.0
46 */
47 public function __clone()
48 {
49 foreach ($this as $property => $value) {
50 if (is_object($value)) {
51 $this->{$property} = clone $value;
52 }
53 }
54 }
55 }
56