summaryrefslogtreecommitdiff
path: root/vendor/guzzle/guzzle/src/Guzzle/Service/Resource/MapResourceIteratorFactory.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/guzzle/guzzle/src/Guzzle/Service/Resource/MapResourceIteratorFactory.php')
-rw-r--r--vendor/guzzle/guzzle/src/Guzzle/Service/Resource/MapResourceIteratorFactory.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/vendor/guzzle/guzzle/src/Guzzle/Service/Resource/MapResourceIteratorFactory.php b/vendor/guzzle/guzzle/src/Guzzle/Service/Resource/MapResourceIteratorFactory.php
new file mode 100644
index 0000000..c71ca9d
--- /dev/null
+++ b/vendor/guzzle/guzzle/src/Guzzle/Service/Resource/MapResourceIteratorFactory.php
@@ -0,0 +1,34 @@
+<?php
+
+namespace Guzzle\Service\Resource;
+
+use Guzzle\Service\Command\CommandInterface;
+
+/**
+ * Resource iterator factory used when explicitly mapping strings to iterator classes
+ */
+class MapResourceIteratorFactory extends AbstractResourceIteratorFactory
+{
+ /** @var array Associative array mapping iterator names to class names */
+ protected $map;
+
+ /** @param array $map Associative array mapping iterator names to class names */
+ public function __construct(array $map)
+ {
+ $this->map = $map;
+ }
+
+ public function getClassName(CommandInterface $command)
+ {
+ $className = $command->getName();
+
+ if (isset($this->map[$className])) {
+ return $this->map[$className];
+ } elseif (isset($this->map['*'])) {
+ // If a wildcard was added, then always use that
+ return $this->map['*'];
+ }
+
+ return null;
+ }
+}