composer package updates
[openemr.git] / vendor / zendframework / zend-feed / src / Reader / StandaloneExtensionManager.php
blob3babc2958357db6d36cb38909b2a86e85c10b921
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
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 */
10 namespace Zend\Feed\Reader;
12 use Zend\Feed\Reader\Exception\InvalidArgumentException;
14 class StandaloneExtensionManager implements ExtensionManagerInterface
16 private $extensions = [
17 'Atom\Entry' => Extension\Atom\Entry::class,
18 'Atom\Feed' => Extension\Atom\Feed::class,
19 'Content\Entry' => Extension\Content\Entry::class,
20 'CreativeCommons\Entry' => Extension\CreativeCommons\Entry::class,
21 'CreativeCommons\Feed' => Extension\CreativeCommons\Feed::class,
22 'DublinCore\Entry' => Extension\DublinCore\Entry::class,
23 'DublinCore\Feed' => Extension\DublinCore\Feed::class,
24 'GooglePlayPodcast\Entry' => Extension\GooglePlayPodcast\Entry::class,
25 'GooglePlayPodcast\Feed' => Extension\GooglePlayPodcast\Feed::class,
26 'Podcast\Entry' => Extension\Podcast\Entry::class,
27 'Podcast\Feed' => Extension\Podcast\Feed::class,
28 'Slash\Entry' => Extension\Slash\Entry::class,
29 'Syndication\Feed' => Extension\Syndication\Feed::class,
30 'Thread\Entry' => Extension\Thread\Entry::class,
31 'WellFormedWeb\Entry' => Extension\WellFormedWeb\Entry::class,
34 /**
35 * Do we have the extension?
37 * @param string $extension
38 * @return bool
40 public function has($extension)
42 return array_key_exists($extension, $this->extensions);
45 /**
46 * Retrieve the extension
48 * @param string $extension
49 * @return Extension\AbstractEntry|Extension\AbstractFeed
51 public function get($extension)
53 $class = $this->extensions[$extension];
54 return new $class();
57 /**
58 * Add an extension.
60 * @param string $name
61 * @param string $class
63 public function add($name, $class)
65 if (is_string($class)
66 && (
67 is_a($class, Extension\AbstractEntry::class, true)
68 || is_a($class, Extension\AbstractFeed::class, true)
70 ) {
71 $this->extensions[$name] = $class;
72 return;
75 throw new InvalidArgumentException(sprintf(
76 'Plugin of type %s is invalid; must implement %2$s\Extension\AbstractFeed '
77 . 'or %2$s\Extension\AbstractEntry',
78 $class,
79 __NAMESPACE__
80 ));
83 /**
84 * Remove an extension.
86 * @param string $name
88 public function remove($name)
90 unset($this->extensions[$name]);