blob: 4658b48f885bef1e7d8d5d36b797569757f1e2de (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
<?php
/**
* SSRS_Object_Abstract
*
* @author arron
*/
class SSRS_Object_Abstract {
public $data = array();
public function __construct($data = null) {
$this->init();
$this->setData($data);
}
public function init() {
}
public function setData($data) {
$clean = $this->_sanitizeData($data);
if (is_array($clean)) {
foreach ($clean AS $key => $value) {
$this->$key = $value;
}
}
return $this;
}
public function __set($key, $value) {
$methodName = 'set' . ucfirst($key);
if (method_exists($this, $methodName)) {
$this->$methodName($value);
} else {
$this->data[$key] = $value;
}
}
protected function _sanitizeData($data, $recursive = false) {
if (is_object($data)) {
$data = get_object_vars($data);
}
if ($recursive && is_array($data)) {
foreach ($data AS $key => $value) {
$data[$key] = $this->_sanitizeData($value);
}
}
return $data;
}
public function __get($key) {
return isset($this->data[$key]) ? $this->data[$key] : null;
}
}
|