Merge pull request #4713 from colemanw/CRM-15710
[civicrm-core.git] / CRM / Contact / DAO / Factory.php
index 233a78356e0228f3502c2230d6709d0fa678cbc9..27d264fb2edab6e81b83762b02a7c0618e9ca93c 100644 (file)
@@ -1,6 +1,8 @@
 <?php
-// $Id$
 
+/**
+ * Class CRM_Contact_DAO_Factory
+ */
 class CRM_Contact_DAO_Factory {
 
   static $_classes = array(
@@ -24,21 +26,12 @@ class CRM_Contact_DAO_Factory {
 
   static $_suffix = '.php';
 
-  static $_preCall = array(
-    'singleton' => '',
-    'business' => 'new',
-    'data' => 'new',
-  );
-
-  static $_extCall = array(
-    'singleton' => '::singleton',
-    'business' => '',
-    'data' => '',
-  );
-
-
-  static
-  function &create($className) {
+  /**
+   * @param $className
+   *
+   * @return mixed
+   */
+  static function &create($className) {
     $type = CRM_Utils_Array::value($className, self::$_classes);
     if (!$type) {
       return CRM_Core_DAO_Factory::create($className);
@@ -49,13 +42,14 @@ class CRM_Contact_DAO_Factory {
 
     require_once ($file . self::$_suffix);
 
-    $newObj = eval(sprintf("return %s %s%s();",
-        self::$_preCall[$type],
-        $class,
-        self::$_extCall[$type]
-      ));
+    if ($type == 'singleton') {
+      $newObj = $class::singleton();
+    }
+    else {
+      // this is either 'business' or 'data'
+      $newObj = new $class;
+    }
 
     return $newObj;
   }
 }
-