| 1 | <?php |
||
| 13 | class ConstObject implements |
||
| 14 | \IteratorAggregate, |
||
| 15 | \Countable |
||
| 16 | { |
||
| 17 | protected $_object; |
||
| 18 | |||
| 19 | 3 | final function __construct(TypedObject $obj) |
|
| 23 | |||
| 24 | 1 | final function __get($name) |
|
| 25 | { |
||
| 26 | 1 | $val = $this->_object->$name; |
|
| 27 | 1 | if ($val instanceof TypedObject) { |
|
| 28 | 1 | return new self($val); |
|
| 29 | } else { |
||
| 30 | 1 | return $val; |
|
| 31 | } |
||
| 32 | } |
||
| 33 | |||
| 34 | 1 | final function __set($name, $value) |
|
| 38 | |||
| 39 | 1 | function getIterator() |
|
| 43 | |||
| 44 | 1 | function count() |
|
| 48 | } |
||
| 49 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.