1: <?php
2:
3: namespace Guzzle\Service\Command\Factory;
4:
5: /**
6: * Command factory used when explicitly mapping strings to command classes
7: */
8: class MapFactory implements FactoryInterface
9: {
10: /**
11: * @var array Associative array mapping command names to classes
12: */
13: protected $map;
14:
15: /**
16: * @param array $map Associative array mapping command names to classes
17: */
18: public function __construct(array $map)
19: {
20: $this->map = $map;
21: }
22:
23: /**
24: * {@inheritdoc}
25: */
26: public function factory($name, array $args = array())
27: {
28: if (isset($this->map[$name])) {
29: $class = $this->map[$name];
30:
31: return new $class($args);
32: }
33: }
34: }
35: