1: <?php
2: /**
3: * Copyright 2010-2014 Horde LLC (http://www.horde.org/)
4: *
5: * See the enclosed file COPYING for license information (GPL). If you
6: * did not receive this file, see http://www.horde.org/licenses/gpl.
7: *
8: * @category Horde
9: * @copyright 2010-2014 Horde LLC
10: * @license http://www.horde.org/licenses/gpl GPL
11: * @package IMP
12: */
13:
14: /**
15: * A Horde_Injector based IMP_Mailbox factory.
16: *
17: * @author Michael Slusarz <slusarz@horde.org>
18: * @category Horde
19: * @copyright 2010-2014 Horde LLC
20: * @license http://www.horde.org/licenses/gpl GPL
21: * @package IMP
22: */
23: class IMP_Factory_Mailbox extends Horde_Core_Factory_Base
24: {
25: /**
26: * Instances.
27: *
28: * @var array
29: */
30: private $_instances = array();
31:
32: /**
33: * Return the IMP_Mailbox:: instance.
34: *
35: * @param string $mbox The IMAP mailbox name.
36: *
37: * @return IMP_Mailbox The singleton mailbox instance.
38: * @throws IMP_Exception
39: */
40: public function create($mbox)
41: {
42: if ($mbox instanceof IMP_Mailbox) {
43: return $mbox;
44: }
45:
46: if (!isset($this->_instances[$mbox])) {
47: $this->_instances[$mbox] = new IMP_Mailbox($mbox);
48: }
49:
50: return $this->_instances[$mbox];
51: }
52:
53: }
54: