Open Journal Systems  3.3.0
ResourceIteratorClassFactory.php
1 <?php
2 
4 
8 
15 {
17  protected $namespaces;
18 
20  protected $inflector;
21 
26  public function __construct($namespaces = array(), InflectorInterface $inflector = null)
27  {
28  $this->namespaces = (array) $namespaces;
29  $this->inflector = $inflector ?: Inflector::getDefault();
30  }
31 
39  public function registerNamespace($namespace)
40  {
41  array_unshift($this->namespaces, $namespace);
42 
43  return $this;
44  }
45 
46  protected function getClassName(CommandInterface $command)
47  {
48  $iteratorName = $this->inflector->camel($command->getName()) . 'Iterator';
49 
50  // Determine the name of the class to load
51  foreach ($this->namespaces as $namespace) {
52  $potentialClassName = $namespace . '\\' . $iteratorName;
53  if (class_exists($potentialClassName)) {
54  return $potentialClassName;
55  }
56  }
57 
58  return false;
59  }
60 }
Guzzle\Service\Resource\ResourceIteratorClassFactory
Definition: ResourceIteratorClassFactory.php:14
Guzzle\Inflection\Inflector\getDefault
static getDefault()
Definition: Inflector.php:18
Guzzle\Service\Resource\ResourceIteratorClassFactory\__construct
__construct($namespaces=array(), InflectorInterface $inflector=null)
Definition: ResourceIteratorClassFactory.php:32
Guzzle\Service\Resource\ResourceIteratorClassFactory\getClassName
getClassName(CommandInterface $command)
Definition: ResourceIteratorClassFactory.php:52
Guzzle\Inflection\InflectorInterface
Definition: InflectorInterface.php:8
Guzzle\Service\Command\CommandInterface
Definition: CommandInterface.php:17
Guzzle\Service\Resource\ResourceIteratorClassFactory\registerNamespace
registerNamespace($namespace)
Definition: ResourceIteratorClassFactory.php:45
Guzzle\Service\Command\CommandInterface\getName
getName()
Guzzle\Service\Resource\ResourceIteratorClassFactory\$namespaces
$namespaces
Definition: ResourceIteratorClassFactory.php:20
Guzzle\Service\Resource
Definition: AbstractResourceIteratorFactory.php:3
Guzzle\Service\Resource\AbstractResourceIteratorFactory
Definition: AbstractResourceIteratorFactory.php:11
Guzzle\Inflection\Inflector
Definition: Inflector.php:8
Guzzle\Service\Resource\ResourceIteratorClassFactory\$inflector
$inflector
Definition: ResourceIteratorClassFactory.php:26