1 | <?php |
||
16 | class Object |
||
17 | { |
||
18 | /** |
||
19 | * Stored entity. |
||
20 | * |
||
21 | * @var array |
||
22 | */ |
||
23 | protected $data; |
||
24 | |||
25 | /** |
||
26 | * Constructor. |
||
27 | * |
||
28 | * @param array $data Object data |
||
29 | */ |
||
30 | 19 | public function __construct(array $data = []) |
|
34 | |||
35 | /** |
||
36 | * Retrieve all the values of the object. |
||
37 | * |
||
38 | * @return array |
||
39 | */ |
||
40 | 2 | public function data() |
|
44 | |||
45 | /** |
||
46 | * Bind data to the object. |
||
47 | * |
||
48 | * @param mixed $data Array | Object |
||
49 | * |
||
50 | * @return self |
||
51 | */ |
||
52 | 3 | public function bind($data) |
|
63 | |||
64 | /** |
||
65 | * Clear stored object. |
||
66 | * |
||
67 | * @return self |
||
68 | */ |
||
69 | 1 | public function clear() |
|
75 | |||
76 | /** |
||
77 | * Get property of the object |
||
78 | * |
||
79 | * @param string $property Name of the property to retrieve |
||
80 | * @param mixed $default Default value if property does not exist |
||
81 | * |
||
82 | * @return mixed |
||
83 | */ |
||
84 | 3 | public function get($property, $default = null) |
|
93 | |||
94 | /** |
||
95 | * Check if the object has a property. |
||
96 | * |
||
97 | * @param string $property Name of the property to check for |
||
98 | * |
||
99 | * @return boolean |
||
100 | */ |
||
101 | 5 | public function has($property) |
|
105 | |||
106 | /** |
||
107 | * Show available properties. |
||
108 | * |
||
109 | * @return array |
||
110 | */ |
||
111 | 1 | public function properties() |
|
115 | |||
116 | /** |
||
117 | * Assign a value of to object property. |
||
118 | * |
||
119 | * @param string $property Name of the property to set |
||
120 | * @param mixed $value Value to assign |
||
121 | * |
||
122 | * @return self |
||
123 | */ |
||
124 | 2 | public function assign($property, $value) |
|
125 | { |
||
126 | 2 | $this->data[$property] = $value; |
|
127 | |||
128 | 2 | return $this; |
|
129 | } |
||
130 | |||
131 | /** |
||
132 | * Set data. |
||
133 | * |
||
134 | * @param array $data Data |
||
135 | * |
||
136 | * @return self |
||
137 | */ |
||
138 | 1 | public function setData(array $data) |
|
144 | |||
145 | /** |
||
146 | * Unassigns an object property. |
||
147 | * |
||
148 | * @param string $property Name of the property to set |
||
149 | * |
||
150 | * @return self |
||
151 | */ |
||
152 | 2 | public function unassign($property) |
|
158 | } |
||
159 |