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

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

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