1: <?php
2: /**
3: * IMP_Quota:: provides an API for retrieving quota details from a mail
4: * server.
5: *
6: * Copyright 2002-2012 Horde LLC (http://www.horde.org/)
7: *
8: * See the enclosed file COPYING for license information (GPL). If you
9: * did not receive this file, see http://www.horde.org/licenses/gpl.
10: *
11: * @author Mike Cochrane <mike@graftonhall.co.nz>
12: * @category Horde
13: * @license http://www.horde.org/licenses/gpl GPL
14: * @package IMP
15: */
16: class IMP_Quota
17: {
18: /**
19: * Attempts to return a concrete instance based on $driver.
20: *
21: * @param string $driver The type of concrete subclass to return.
22: * @param array $params A hash containing any additional configuration
23: * parameters a subclass might need.
24: *
25: * @return IMP_Quota_Driver The concrete instance.
26: * @throws IMP_Exception
27: */
28: static public function factory($driver, $params = array())
29: {
30: $driver = basename($driver);
31: $class = __CLASS__ . '_' . ucfirst($driver);
32:
33: if (class_exists($class)) {
34: return new $class($params);
35: }
36:
37: throw new IMP_Exception('Could not create ' . __CLASS__ . ' instance: ' . $driver);
38: }
39:
40: }
41: