Open Journal Systems  3.3.0
PreComputedInflector.php
1 <?php
2 
3 namespace Guzzle\Inflection;
4 
9 {
11  protected $mapping = array(
12  'snake' => array(),
13  'camel' => array()
14  );
15 
17  protected $decoratedInflector;
18 
25  public function __construct(InflectorInterface $inflector, array $snake = array(), array $camel = array(), $mirror = false)
26  {
27  if ($mirror) {
28  $camel = array_merge(array_flip($snake), $camel);
29  $snake = array_merge(array_flip($camel), $snake);
30  }
31 
32  $this->decoratedInflector = $inflector;
33  $this->mapping = array(
34  'snake' => $snake,
35  'camel' => $camel
36  );
37  }
38 
39  public function snake($word)
40  {
41  return isset($this->mapping['snake'][$word])
42  ? $this->mapping['snake'][$word]
43  : $this->decoratedInflector->snake($word);
44  }
45 
53  public function camel($word)
54  {
55  return isset($this->mapping['camel'][$word])
56  ? $this->mapping['camel'][$word]
57  : $this->decoratedInflector->camel($word);
58  }
59 }
Guzzle\Inflection\PreComputedInflector\$mapping
$mapping
Definition: PreComputedInflector.php:14
Guzzle\Inflection\PreComputedInflector
Definition: PreComputedInflector.php:8
Guzzle\Inflection\PreComputedInflector\snake
snake($word)
Definition: PreComputedInflector.php:45
Guzzle\Inflection\PreComputedInflector\__construct
__construct(InflectorInterface $inflector, array $snake=array(), array $camel=array(), $mirror=false)
Definition: PreComputedInflector.php:31
Guzzle\Inflection\InflectorInterface
Definition: InflectorInterface.php:8
Guzzle\Inflection
Definition: Inflector.php:3
Guzzle\Inflection\PreComputedInflector\camel
camel($word)
Definition: PreComputedInflector.php:59
Guzzle\Inflection\PreComputedInflector\$decoratedInflector
$decoratedInflector
Definition: PreComputedInflector.php:23