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

  • AliasFactory
  • CompositeFactory
  • ConcreteClassFactory
  • MapFactory
  • ServiceDescriptionFactory

Interfaces

  • FactoryInterface
  • Overview
  • Namespace
  • Class
  • Tree
  • Todo
 1: <?php
 2: 
 3: namespace Guzzle\Service\Command\Factory;
 4: 
 5: use Guzzle\Common\Exception\InvalidArgumentException;
 6: use Guzzle\Service\ClientInterface;
 7: 
 8: /**
 9:  * Command factory used when you need to provide aliases to commands
10:  */
11: class AliasFactory implements FactoryInterface
12: {
13:     /**
14:      * @var array Associative array mapping command aliases to the aliased command
15:      */
16:     protected $aliases;
17: 
18:     /**
19:      * @var ClientInterface Client used to retry using aliases
20:      */
21:     protected $client;
22: 
23:     /**
24:      * @param ClientInterface $client  Client used to retry with the alias
25:      * @param array           $aliases Associative array mapping aliases to the alias
26:      */
27:     public function __construct(ClientInterface $client, array $aliases)
28:     {
29:         $this->client = $client;
30:         $this->aliases = $aliases;
31:     }
32: 
33:     /**
34:      * {@inheritdoc}
35:      */
36:     public function factory($name, array $args = array())
37:     {
38:         if (isset($this->aliases[$name])) {
39:             try {
40:                 return $this->client->getCommand($this->aliases[$name], $args);
41:             } catch (InvalidArgumentException $e) {
42:                 return null;
43:             }
44:         }
45:     }
46: }
47: 
php-coveralls API documentation generated by ApiGen 2.8.0