1 | <?php |
||
15 | class JailedDocument implements \ArrayAccess, \IteratorAggregate, \JsonSerializable |
||
16 | { |
||
17 | /** @var string[] */ |
||
18 | private $whiteListFunctions; |
||
19 | |||
20 | /** @var string[] */ |
||
21 | private $jailedFunctions; |
||
22 | |||
23 | /** @var TemplateReadyDocument */ |
||
24 | private $object; |
||
25 | |||
26 | /** |
||
27 | * JailObject constructor. |
||
28 | * |
||
29 | * @param TemplateReadyDocument $object the object that will be jailed |
||
30 | * @param array $whiteListFunctions a list of function names that can be called |
||
31 | * @param array $jailedFunctions a list of functions that will be redirected to another function |
||
32 | */ |
||
33 | 53 | public function __construct(TemplateReadyDocument &$object, array $whiteListFunctions, array $jailedFunctions = []) |
|
39 | |||
40 | 11 | public function __call($name, $arguments) |
|
62 | |||
63 | /** |
||
64 | * Check if the jailed object is an instance of a given class. |
||
65 | * |
||
66 | * @param string $class |
||
67 | * |
||
68 | * @return bool |
||
69 | */ |
||
70 | public function _coreInstanceOf($class) |
||
71 | { |
||
72 | return ($this->object instanceof $class) || is_subclass_of($this->object, $class); |
||
73 | } |
||
74 | |||
75 | /// |
||
76 | // ArrayAccess Implementation |
||
77 | /// |
||
78 | |||
79 | /** |
||
80 | * {@inheritdoc} |
||
81 | */ |
||
82 | 22 | public function offsetExists($offset) |
|
86 | |||
87 | /** |
||
88 | * {@inheritdoc} |
||
89 | */ |
||
90 | 32 | public function offsetGet($offset) |
|
94 | |||
95 | /** |
||
96 | * {@inheritdoc} |
||
97 | */ |
||
98 | public function offsetSet($offset, $value) |
||
102 | |||
103 | /** |
||
104 | * {@inheritdoc} |
||
105 | */ |
||
106 | public function offsetUnset($offset) |
||
110 | |||
111 | /// |
||
112 | // IteratorAggregate implementation |
||
113 | /// |
||
114 | |||
115 | /** |
||
116 | * {@inheritdoc} |
||
117 | */ |
||
118 | 19 | public function getIterator() |
|
122 | |||
123 | /// |
||
124 | // JsonSerializable implementation |
||
125 | /// |
||
126 | |||
127 | /** |
||
128 | * {@inheritdoc} |
||
129 | */ |
||
130 | public function jsonSerialize() |
||
134 | } |
||
135 |