| @@ 58-68 (lines=11) @@ | ||
| 55 | public function offsetGet($offset) |
|
| 56 | { |
|
| 57 | $res = null; |
|
| 58 | if(is_array($this->obj)){ |
|
| 59 | $res = &$this->obj[$offset]; |
|
| 60 | }elseif(self::hasProperty($this->obj, $offset)){ |
|
| 61 | $res = &$this->obj->{$offset}; |
|
| 62 | }elseif(method_exists($this->obj, 'get')){ |
|
| 63 | $res = $this->obj->get($offset); |
|
| 64 | }elseif(method_exists($this->obj, $method = 'get'.ucfirst($offset))){ |
|
| 65 | $res = $this->obj->{$method}(); |
|
| 66 | }else{ |
|
| 67 | throw new \InvalidArgumentException("offsetGet($offset) failed"); |
|
| 68 | } |
|
| 69 | if(is_array($res) || is_object($res)){ |
|
| 70 | return new self($res); |
|
| 71 | } |
|
| @@ 89-99 (lines=11) @@ | ||
| 86 | */ |
|
| 87 | public function offsetSet($offset, $value) |
|
| 88 | { |
|
| 89 | if(is_array($this->obj)){ |
|
| 90 | $this->obj[$offset] = $value; |
|
| 91 | }elseif(self::hasProperty($this->obj, $offset)){ |
|
| 92 | $this->obj->{$offset} = $value; |
|
| 93 | }elseif(method_exists($this->obj, 'set')){ |
|
| 94 | $this->obj->set($offset, $value); |
|
| 95 | }elseif(method_exists($this->obj, $method = 'set'.ucfirst($offset))){ |
|
| 96 | $this->obj->{$method}($value); |
|
| 97 | }else{ |
|
| 98 | throw new \BadMethodCallException("can not set $offset"); |
|
| 99 | } |
|
| 100 | } |
|
| 101 | ||
| 102 | /** |
|