diff options
Diffstat (limited to 'vendor/guzzle/guzzle/src/Guzzle/Service/Command/Factory/MapFactory.php')
-rw-r--r-- | vendor/guzzle/guzzle/src/Guzzle/Service/Command/Factory/MapFactory.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/vendor/guzzle/guzzle/src/Guzzle/Service/Command/Factory/MapFactory.php b/vendor/guzzle/guzzle/src/Guzzle/Service/Command/Factory/MapFactory.php new file mode 100644 index 0000000..0ad80bc --- /dev/null +++ b/vendor/guzzle/guzzle/src/Guzzle/Service/Command/Factory/MapFactory.php @@ -0,0 +1,27 @@ +<?php + +namespace Guzzle\Service\Command\Factory; + +/** + * Command factory used when explicitly mapping strings to command classes + */ +class MapFactory implements FactoryInterface +{ + /** @var array Associative array mapping command names to classes */ + protected $map; + + /** @param array $map Associative array mapping command names to classes */ + public function __construct(array $map) + { + $this->map = $map; + } + + public function factory($name, array $args = array()) + { + if (isset($this->map[$name])) { + $class = $this->map[$name]; + + return new $class($args); + } + } +} |