3 namespace Drupal\webprofiler;
6 * Generic class Decorator.
18 * @param object $object
19 * The object to decorate.
21 public function __construct($object) {
22 $this->object = $object;
26 * Return the original (i.e. non decorated) object.
29 * The original object.
31 public function getOriginalObject() {
32 $object = $this->object;
33 while ($object instanceof Decorator) {
34 $object = $object->getOriginalObject();
40 * Returns true if $method is a PHP callable.
42 * @param string $method
44 * @param bool $checkSelf
48 public function isCallable($method, $checkSelf = FALSE) {
49 //Check the original object
50 $object = $this->getOriginalObject();
51 if (is_callable([$object, $method])) {
55 $object = $checkSelf ? $this : $this->object;
56 while ($object instanceof Decorator) {
57 if (is_callable([$object, $method])) {
60 $object = $this->object;
73 public function __call($method, $args) {
74 if ($object = $this->isCallable($method)) {
75 return call_user_func_array([$object, $method], $args);
78 'Undefined method - ' . get_class($this->getOriginalObject()) . '::' . $method
87 public function __get($property) {
88 $object = $this->getOriginalObject();
89 if (property_exists($object, $property)) {
90 return $object->$property;