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\Inflection\InflectorInterface;
 6: use Guzzle\Inflection\Inflector;
 7: use Guzzle\Service\ClientInterface;
 8: 
 9: /**
10:  * Command factory used to create commands referencing concrete command classes
11:  */
12: class ConcreteClassFactory implements FactoryInterface
13: {
14:     /**
15:      * @var ClientInterface
16:      */
17:     protected $client;
18: 
19:     /**
20:      * @var InflectorInterface
21:      */
22:     protected $inflector;
23: 
24:     /**
25:      * @param ClientInterface    $client    Client that owns the commands
26:      * @param InflectorInterface $inflector Inflector used to resolve class names
27:      */
28:     public function __construct(ClientInterface $client, InflectorInterface $inflector = null)
29:     {
30:         $this->client = $client;
31:         $this->inflector = $inflector ?: Inflector::getDefault();
32:     }
33: 
34:     /**
35:      * {@inheritdoc}
36:      */
37:     public function factory($name, array $args = array())
38:     {
39:         // Determine the class to instantiate based on the namespace of the current client and the default directory
40:         $prefix = $this->client->getConfig('command.prefix');
41:         if (!$prefix) {
42:             // The prefix can be specified in a factory method and is cached
43:             $prefix = implode('\\', array_slice(explode('\\', get_class($this->client)), 0, -1)) . '\\Command\\';
44:             $this->client->getConfig()->set('command.prefix', $prefix);
45:         }
46: 
47:         $class = $prefix . str_replace(' ', '\\', ucwords(str_replace('.', ' ', $this->inflector->camel($name))));
48: 
49:         // Create the concrete command if it exists
50:         if (class_exists($class)) {
51:             return new $class($args);
52:         }
53:     }
54: }
55: 
php-coveralls API documentation generated by ApiGen 2.8.0