Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
SeedDMS_Core_Decorator | |
0.00% |
0 / 5 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
__call | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | /** |
3 | * Implementation of the decorator pattern |
4 | * |
5 | * @category DMS |
6 | * @package SeedDMS_Core |
7 | * @license GPL 2 |
8 | * @version @version@ |
9 | * @author Uwe Steinmann <uwe@steinmann.cx> |
10 | * @copyright Copyright (C) 2010, Uwe Steinmann |
11 | * @version Release: @package_version@ |
12 | */ |
13 | |
14 | |
15 | /** |
16 | * Class which implements a simple decorator pattern |
17 | * |
18 | * @category DMS |
19 | * @package SeedDMS_Core |
20 | * @version @version@ |
21 | * @author Uwe Steinmann <uwe@steinmann.cx> |
22 | * @copyright Copyright (C) 2010, Uwe Steinmann |
23 | * @version Release: @package_version@ |
24 | */ |
25 | class SeedDMS_Core_Decorator { |
26 | protected $o; |
27 | |
28 | public function __construct($object) { |
29 | $this->o = $object; |
30 | } |
31 | |
32 | public function __call($method, $args) |
33 | { |
34 | if (!method_exists($this->o, $method)) { |
35 | throw new Exception("Undefined method $method attempt."); |
36 | } |
37 | /* In case the called method returns the object itself, then return this object */ |
38 | $result = call_user_func_array(array($this->o, $method), $args); |
39 | return $result === $this->o ? $this : $result; |
40 | } |
41 | } |
42 |