Open Journal Systems  3.3.0
ServiceDescriptionFactory.php
1 <?php
2 
4 
7 
12 {
14  protected $description;
15 
17  protected $inflector;
18 
24  {
25  $this->setServiceDescription($description);
26  $this->inflector = $inflector;
27  }
28 
37  {
38  $this->description = $description;
39 
40  return $this;
41  }
42 
48  public function getServiceDescription()
49  {
50  return $this->description;
51  }
52 
53  public function factory($name, array $args = array())
54  {
55  $command = $this->description->getOperation($name);
56 
57  // If a command wasn't found, then try to uppercase the first letter and try again
58  if (!$command) {
59  $command = $this->description->getOperation(ucfirst($name));
60  // If an inflector was passed, then attempt to get the command using snake_case inflection
61  if (!$command && $this->inflector) {
62  $command = $this->description->getOperation($this->inflector->snake($name));
63  }
64  }
65 
66  if ($command) {
67  $class = $command->getClass();
68  return new $class($args, $command, $this->description);
69  }
70  }
71 }
Guzzle\Service\Command\Factory\ServiceDescriptionFactory\$inflector
$inflector
Definition: ServiceDescriptionFactory.php:23
Guzzle\Service\Command\Factory\ServiceDescriptionFactory\getServiceDescription
getServiceDescription()
Definition: ServiceDescriptionFactory.php:54
Guzzle\Inflection\InflectorInterface
Definition: InflectorInterface.php:8
Guzzle\Service\Description\ServiceDescriptionInterface
Definition: ServiceDescriptionInterface.php:8
Guzzle\Service\Command\Factory
Definition: AliasFactory.php:3
Guzzle\Service\Command\Factory\ServiceDescriptionFactory\factory
factory($name, array $args=array())
Definition: ServiceDescriptionFactory.php:59
Guzzle\Service\Command\Factory\ServiceDescriptionFactory\$description
$description
Definition: ServiceDescriptionFactory.php:17
Guzzle\Service\Command\Factory\ServiceDescriptionFactory\__construct
__construct(ServiceDescriptionInterface $description, InflectorInterface $inflector=null)
Definition: ServiceDescriptionFactory.php:29
Guzzle\Service\Command\Factory\ServiceDescriptionFactory\setServiceDescription
setServiceDescription(ServiceDescriptionInterface $description)
Definition: ServiceDescriptionFactory.php:42
Guzzle\Service\Command\Factory\FactoryInterface
Definition: FactoryInterface.php:10
Guzzle\Service\Command\Factory\ServiceDescriptionFactory
Definition: ServiceDescriptionFactory.php:11