/** * @param Inflector $inflector * @param array $array */ public function __construct(Inflector $inflector, array $array) { $this->inflector = $inflector; $this->inflector->setTarget(':name')->setRules([':name' => ['Word\\CamelCaseToUnderscore', 'StringToLower']]); foreach ($array as $key => $value) { if (is_array($value)) { $this->data[$key] = new static($this->inflector, $value); } else { $this->data[$key] = $value; } $this->count++; } }
public function testFilterTransformsStringAccordingToRules() { $this->inflector->setTarget(':controller/:action.:suffix')->addRules(array(':controller' => array('Word\\CamelCaseToDash'), ':action' => array('Word\\CamelCaseToDash'), 'suffix' => 'phtml')); $filter = $this->inflector; $filtered = $filter(array('controller' => 'FooBar', 'action' => 'bazBat')); $this->assertEquals('Foo-Bar/baz-Bat.phtml', $filtered); }