summaryrefslogtreecommitdiffstats
path: root/library/SSRS/Object/Abstract.php
diff options
context:
space:
mode:
Diffstat (limited to 'library/SSRS/Object/Abstract.php')
-rwxr-xr-xlibrary/SSRS/Object/Abstract.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/library/SSRS/Object/Abstract.php b/library/SSRS/Object/Abstract.php
new file mode 100755
index 0000000..40482a0
--- /dev/null
+++ b/library/SSRS/Object/Abstract.php
@@ -0,0 +1,48 @@
+<?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) {
+ if ($data instanceof stdClass) {
+ $data = get_object_vars($data);
+ }
+
+ if (is_array($data)) {
+ foreach ($data 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;
+ }
+ }
+
+ public function __get($key) {
+ return isset($this->data[$key]) ? $this->data[$key] : null;
+ }
+
+} \ No newline at end of file