Browse Source

dymanic dbo cast

tags/0.1.0
Robin Thoni 9 years ago
parent
commit
13cdac8137
1 changed files with 12 additions and 0 deletions
  1. 12
    0
      src/Utils/LuDbo.php

+ 12
- 0
src/Utils/LuDbo.php View File

10
     {
10
     {
11
         return json_encode($this);
11
         return json_encode($this);
12
     }
12
     }
13
+
14
+    /**
15
+     * @param $newClass $newClass
16
+     * @return mixed
17
+     */
18
+    public function castAs($newClass) {
19
+        $obj = new $newClass;
20
+        foreach (get_object_vars($this) as $key => $name) {
21
+            $obj->$key = $name;
22
+        }
23
+        return $obj;
24
+    }
13
 }
25
 }

Loading…
Cancel
Save