1<?php
2
3/**
4 * Swift Mailer Cache Factory class
5 * Please read the LICENSE file
6 * @author Chris Corbyn <chris@w3style.co.uk>
7 * @package Swift_Cache
8 * @license GNU Lesser General Public License
9 */
10
11require_once dirname(__FILE__) . "/ClassLoader.php";
12
13/**
14 * Makes instances of the cache the user has defined
15 * @package Swift_Cache
16 * @author Chris Corbyn <chris@w3style.co.uk>
17 */
18class Swift_CacheFactory
19{
20  /**
21   * The name of the class which defines the cache
22   * @var string Case SenSITivE
23   */
24  protected static $className = "Swift_Cache_Memory";
25
26  /**
27   * Set the name of the class which is supposed to be used
28   * This also includes the file
29   * @param string The class name
30   */
31  public static function setClassName($name)
32  {
33    Swift_ClassLoader::load($name);
34    self::$className = $name;
35  }
36  /**
37   * Return a new instance of the cache object
38   * @return Swift_Cache
39   */
40  public static function getCache()
41  {
42    $className = self::$className;
43    Swift_ClassLoader::load($className);
44    $instance = new $className();
45    return $instance;
46  }
47}
48