f7946b7914eb32ce58fe0bec9f6469f37b75c05b
[yaffs-website] / vendor / zendframework / zend-feed / src / Reader / ExtensionManager.php
1 <?php
2 /**
3  * Zend Framework (http://framework.zend.com/)
4  *
5  * @link      http://github.com/zendframework/zf2 for the canonical source repository
6  * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7  * @license   http://framework.zend.com/license/new-bsd New BSD License
8  */
9
10 namespace Zend\Feed\Reader;
11
12 /**
13  * Default implementation of ExtensionManagerInterface
14  *
15  * Decorator of ExtensionPluginManager.
16  */
17 class ExtensionManager implements ExtensionManagerInterface
18 {
19     protected $pluginManager;
20
21     /**
22      * Constructor
23      *
24      * Seeds the extension manager with a plugin manager; if none provided,
25      * creates an instance.
26      *
27      * @param  null|ExtensionPluginManager $pluginManager
28      */
29     public function __construct(ExtensionPluginManager $pluginManager = null)
30     {
31         if (null === $pluginManager) {
32             $pluginManager = new ExtensionPluginManager();
33         }
34         $this->pluginManager = $pluginManager;
35     }
36
37     /**
38      * Method overloading
39      *
40      * Proxy to composed ExtensionPluginManager instance.
41      *
42      * @param  string $method
43      * @param  array $args
44      * @return mixed
45      * @throws Exception\BadMethodCallException
46      */
47     public function __call($method, $args)
48     {
49         if (! method_exists($this->pluginManager, $method)) {
50             throw new Exception\BadMethodCallException(sprintf(
51                 'Method by name of %s does not exist in %s',
52                 $method,
53                 __CLASS__
54             ));
55         }
56         return call_user_func_array([$this->pluginManager, $method], $args);
57     }
58
59     /**
60      * Get the named extension
61      *
62      * @param  string $name
63      * @return Extension\AbstractEntry|Extension\AbstractFeed
64      */
65     public function get($name)
66     {
67         return $this->pluginManager->get($name);
68     }
69
70     /**
71      * Do we have the named extension?
72      *
73      * @param  string $name
74      * @return bool
75      */
76     public function has($name)
77     {
78         return $this->pluginManager->has($name);
79     }
80 }