Completed
Pull Request — master (#5)
by Viacheslav
08:29
created

MagicMap::setDataToPropertyMap()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
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
}