public inflectPackageVars ( $vars ) |
public function inflectPackageVars($vars)
{
if ($this->matchesCakeVersion('>=', '3.0.0')) {
return $vars;
}
$nameParts = explode('/', $vars['name']);
foreach ($nameParts as &$value) {
$value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value));
$value = str_replace(array('-', '_'), ' ', $value);
$value = str_replace(' ', '', ucwords($value));
}
$vars['name'] = implode('/', $nameParts);
return $vars;
}
/** * testInflectPackageVars * * @return void */ public function testInflectPackageVars() { $installer = new CakePHPInstaller($this->package, $this->composer); $result = $installer->inflectPackageVars(array('name' => 'CamelCased')); $this->assertEquals($result, array('name' => 'CamelCased')); $installer = new CakePHPInstaller($this->package, $this->composer); $result = $installer->inflectPackageVars(array('name' => 'with-dash')); $this->assertEquals($result, array('name' => 'WithDash')); $installer = new CakePHPInstaller($this->package, $this->composer); $result = $installer->inflectPackageVars(array('name' => 'with_underscore')); $this->assertEquals($result, array('name' => 'WithUnderscore')); }