From: Michael M Slusarz Date: Wed, 10 Dec 2008 20:24:43 +0000 (-0700) Subject: Clean up some instantiation code. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=5649c765f8914b3932556208a74f7a96092e6ee3;p=horde.git Clean up some instantiation code. --- diff --git a/imp/lib/Fetchmail.php b/imp/lib/Fetchmail.php index 8a85e57a9..d26ba65a2 100644 --- a/imp/lib/Fetchmail.php +++ b/imp/lib/Fetchmail.php @@ -61,18 +61,12 @@ abstract class IMP_Fetchmail * @return mixed The newly created concrete IMP_Fetchmail instance, or * false on error. */ - static public function &factory($driver, $params = array()) + static public function factory($driver, $params = array()) { - $driver = basename($driver); - require_once dirname(__FILE__) . '/Fetchmail/' . $driver . '.php'; - $class = 'IMP_Fetchmail_' . $driver; - if (class_exists($class)) { - $fetchmail = new $class($params); - } else { - $fetchmail = false; - } - - return $fetchmail; + $class = 'IMP_Fetchmail_' . basename($driver); + return class_exists($class) + ? new $class($params) + : false; } /** @@ -92,7 +86,6 @@ abstract class IMP_Fetchmail if (!is_dir($file)) { $driver = basename($file, '.php'); $class = 'IMP_Fetchmail_' . $driver; - require_once dirname(__FILE__) . '/Fetchmail/' . $file; if (is_callable(array($class, 'description')) && ($descrip = call_user_func(array($class, 'description')))) { $drivers[$driver] = $descrip; @@ -143,7 +136,7 @@ abstract class IMP_Fetchmail foreach ($accounts as $val) { $params = $fm_account->getAllValues($val); - $driver = &IMP_Fetchmail::factory($params['driver'], $params); + $driver = IMP_Fetchmail::factory($params['driver'], $params); if ($driver === false) { continue; }