|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Swaggest\JsonSchema; |
|
4
|
|
|
|
|
5
|
|
|
class MagicMap implements \ArrayAccess, \JsonSerializable |
|
6
|
|
|
{ |
|
7
|
|
|
protected $__arrayOfData = array(); |
|
8
|
|
|
|
|
9
|
|
|
public function __set($name, $column) |
|
10
|
|
|
{ |
|
11
|
|
|
$this->__arrayOfData[$name] = $column; |
|
12
|
|
|
return $this; |
|
13
|
|
|
} |
|
14
|
|
|
|
|
15
|
|
|
public function &__get($name) |
|
16
|
|
|
{ |
|
17
|
|
|
if (isset($this->__arrayOfData[$name])) { |
|
18
|
|
|
return $this->__arrayOfData[$name]; |
|
19
|
|
|
} else { |
|
20
|
|
|
$tmp = null; |
|
21
|
|
|
return $tmp; |
|
22
|
|
|
} |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public function offsetExists($offset) |
|
26
|
|
|
{ |
|
27
|
|
|
return array_key_exists($offset, $this->__arrayOfData); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function &offsetGet($offset) |
|
31
|
|
|
{ |
|
32
|
|
|
if (isset($this->__arrayOfData[$offset])) { |
|
33
|
|
|
return $this->__arrayOfData[$offset]; |
|
34
|
|
|
} else { |
|
35
|
|
|
$tmp = null; |
|
36
|
|
|
return $tmp; |
|
37
|
|
|
} |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function offsetSet($offset, $value) |
|
41
|
|
|
{ |
|
42
|
|
|
$this->__set($offset, $value); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function offsetUnset($offset) |
|
46
|
|
|
{ |
|
47
|
|
|
unset($this->__arrayOfData[$offset]); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function &toArray() |
|
51
|
|
|
{ |
|
52
|
|
|
return $this->__arrayOfData; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function jsonSerialize() |
|
56
|
|
|
{ |
|
57
|
|
|
return (object)$this->__arrayOfData; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
private $__propertyToDataMap; |
|
61
|
|
|
public function setPropertyToDataMap($map) |
|
62
|
|
|
{ |
|
63
|
|
|
$this->__propertyToDataMap = $map; |
|
64
|
|
|
return $this; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function getPropertyToDataMap() |
|
68
|
|
|
{ |
|
69
|
|
|
return $this->__propertyToDataMap; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
private $__dataToPropertyMap; |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @return mixed |
|
76
|
|
|
*/ |
|
77
|
|
|
public function getDataToPropertyMap() |
|
78
|
|
|
{ |
|
79
|
|
|
return $this->__dataToPropertyMap; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @param mixed $_dataToPropertyMap |
|
84
|
|
|
* @return MagicMap |
|
85
|
|
|
*/ |
|
86
|
|
|
public function setDataToPropertyMap($_dataToPropertyMap) |
|
87
|
|
|
{ |
|
88
|
|
|
$this->__dataToPropertyMap = $_dataToPropertyMap; |
|
89
|
|
|
return $this; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
} |