1 | <?php |
||
8 | trait Accessors |
||
9 | { |
||
10 | private $_magic = []; |
||
11 | |||
12 | 26 | public function __get($property) |
|
24 | |||
25 | 12 | public function __set($property, $value) |
|
26 | { |
||
27 | 12 | $setter = 'set' . ucfirst($property); |
|
28 | |||
29 | 12 | if (method_exists($this, $setter)) { |
|
30 | 12 | $this->$setter($value); |
|
31 | } elseif (method_exists($this, 'get' . ucfirst($property))) { |
||
32 | throw new ReadOnlyException("Property \$$property is read-only."); |
||
33 | } else { |
||
34 | $this->_magic[$property] = $value; |
||
35 | } |
||
36 | 12 | } |
|
37 | |||
38 | public function __isset($property) |
||
42 | |||
43 | public function __unset($property) |
||
47 | |||
48 | public function _get($property) |
||
52 | |||
53 | public function _set($property, $value) |
||
57 | |||
58 | public function applyOptions(array $options) |
||
64 | } |
||
65 |