Overview

Namespaces

  • Contrib
    • Bundle
      • CoverallsBundle
        • Console
        • Entity
      • CoverallsV1Bundle
        • Api
        • Collector
        • Command
        • Config
        • Entity
          • Git
    • Component
      • File
      • Log
      • System
        • Git
  • Guzzle
    • Batch
      • Exception
    • Cache
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
      • QueryAggregator
    • Inflection
    • Iterator
    • Log
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Async
      • Backoff
      • Cache
      • Cookie
        • CookieJar
        • Exception
      • CurlAuth
      • ErrorResponse
        • Exception
      • History
      • Log
      • Md5
      • Mock
      • Oauth
    • Service
      • Builder
      • Command
        • Factory
        • LocationVisitor
          • Request
          • Response
      • Description
      • Exception
      • Resource
    • Stream
  • PHP
  • Psr
    • Log
  • Symfony
    • Component
      • Config
        • Definition
          • Builder
          • Exception
        • Exception
        • Loader
        • Resource
        • Util
      • Console
        • Command
        • Formatter
        • Helper
        • Input
        • Output
        • Tester
      • EventDispatcher
        • Debug
      • Finder
        • Adapter
        • Comparator
        • Exception
        • Expression
        • Iterator
        • Shell
      • Stopwatch
      • Yaml
        • Exception

Classes

  • AbstractResourceIteratorFactory
  • CompositeResourceIteratorFactory
  • MapResourceIteratorFactory
  • Model
  • ResourceIterator
  • ResourceIteratorApplyBatched
  • ResourceIteratorClassFactory

Interfaces

  • ResourceIteratorFactoryInterface
  • ResourceIteratorInterface
  • Overview
  • Namespace
  • Class
  • Tree
  • Todo
 1: <?php
 2: 
 3: namespace Guzzle\Service\Resource;
 4: 
 5: use Guzzle\Common\Exception\InvalidArgumentException;
 6: use Guzzle\Service\Command\CommandInterface;
 7: 
 8: /**
 9:  * Factory that utilizes multiple factories for creating iterators
10:  */
11: class CompositeResourceIteratorFactory implements ResourceIteratorFactoryInterface
12: {
13:     /**
14:      * @var array Array of factories
15:      */
16:     protected $factories;
17: 
18:     /**
19:      * @param array $factories Array of factories used to instantiate iterators
20:      */
21:     public function __construct(array $factories)
22:     {
23:         $this->factories = $factories;
24:     }
25: 
26:     /**
27:      * {@inheritdoc}
28:      */
29:     public function build(CommandInterface $command, array $options = array())
30:     {
31:         if (!($factory = $this->getFactory($command))) {
32:             throw new InvalidArgumentException('Iterator was not found for ' . $command->getName());
33:         }
34: 
35:         return $factory->build($command, $options);
36:     }
37: 
38:     /**
39:      * {@inheritdoc}
40:      */
41:     public function canBuild(CommandInterface $command)
42:     {
43:         return $this->getFactory($command) !== false;
44:     }
45: 
46:     /**
47:      * Add a factory to the composite factory
48:      *
49:      * @param ResourceIteratorFactoryInterface $factory Factory to add
50:      *
51:      * @return self
52:      */
53:     public function addFactory(ResourceIteratorFactoryInterface $factory)
54:     {
55:         $this->factories[] = $factory;
56: 
57:         return $this;
58:     }
59: 
60:     /**
61:      * Get the factory that matches the command object
62:      *
63:      * @param CommandInterface $command Command retrieving the iterator for
64:      *
65:      * @return ResourceIteratorFactoryInterface|bool
66:      */
67:     protected function getFactory(CommandInterface $command)
68:     {
69:         foreach ($this->factories as $factory) {
70:             if ($factory->canBuild($command)) {
71:                 return $factory;
72:             }
73:         }
74: 
75:         return false;
76:     }
77: }
78: 
php-coveralls API documentation generated by ApiGen 2.8.0