Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -167,7 +167,8 @@ class Converter
|
||||
if (isset($entityParams['indexes']) && is_array($entityParams['indexes'])) {
|
||||
foreach ($entityParams['indexes'] as $indexName => $indexParams) {
|
||||
if (is_array($indexParams['columns'])) {
|
||||
$indexList[$indexName] = $indexParams['columns'];
|
||||
$uIndexName = strtoupper( Util::toUnderScore($indexName) );
|
||||
$indexList[$uIndexName] = Util::toUnderScore($indexParams['columns']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,13 +63,21 @@ class Util
|
||||
* Convert name to Camel Case format, ex. camel_case to camelCase
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $symbol
|
||||
* @param string | array $symbol
|
||||
* @param boolean $capitaliseFirstChar
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function toCamelCase($name, $symbol = '_', $capitaliseFirstChar = false)
|
||||
{
|
||||
if (is_array($name)) {
|
||||
foreach ($name as &$value) {
|
||||
$value = static::toCamelCase($value, $symbol, $capitaliseFirstChar);
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
if($capitaliseFirstChar) {
|
||||
$name[0] = strtoupper($name[0]);
|
||||
}
|
||||
@@ -85,12 +93,20 @@ class Util
|
||||
* Convert name from Camel Case format.
|
||||
* ex. camelCase to camel-case
|
||||
*
|
||||
* @param string $name
|
||||
* @param string | array $name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function fromCamelCase($name, $symbol = '_')
|
||||
{
|
||||
if (is_array($name)) {
|
||||
foreach ($name as &$value) {
|
||||
$value = static::fromCamelCase($value, $symbol);
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
$name[0] = strtolower($name[0]);
|
||||
return preg_replace_callback('/([A-Z])/', function ($matches) use ($symbol) {
|
||||
return $symbol . strtolower($matches[1]);
|
||||
@@ -101,7 +117,7 @@ class Util
|
||||
* Convert name from Camel Case format to underscore.
|
||||
* ex. camelCase to camel_case
|
||||
*
|
||||
* @param string $name
|
||||
* @param string | array $name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
||||
@@ -13,25 +13,61 @@ class UtilTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testToCamelCase()
|
||||
{
|
||||
$this->assertEquals('detail', Util::toCamelCase('detail'));
|
||||
$this->assertEquals('detailView', Util::toCamelCase('detail-view', '-'));
|
||||
$this->assertEquals('myDetailView', Util::toCamelCase('my_detail_view'));
|
||||
$this->assertEquals('detail', Util::toCamelCase('detail'));
|
||||
$this->assertEquals('detailView', Util::toCamelCase('detail-view', '-'));
|
||||
$this->assertEquals('myDetailView', Util::toCamelCase('my_detail_view'));
|
||||
|
||||
$input = array(
|
||||
'detail',
|
||||
'my_detail_view',
|
||||
);
|
||||
$result = array(
|
||||
'detail',
|
||||
'myDetailView',
|
||||
);
|
||||
$this->assertEquals($result, Util::toCamelCase($input));
|
||||
}
|
||||
|
||||
public function testFromCamelCase()
|
||||
{
|
||||
$this->assertEquals('detail', Util::fromCamelCase('detail'));
|
||||
$this->assertEquals('detail-view', Util::fromCamelCase('detailView', '-'));
|
||||
$this->assertEquals('my_detail_view', Util::fromCamelCase('myDetailView'));
|
||||
$this->assertEquals('my_f_f', Util::fromCamelCase('myFF'));
|
||||
$this->assertEquals('detail', Util::fromCamelCase('detail'));
|
||||
$this->assertEquals('detail-view', Util::fromCamelCase('detailView', '-'));
|
||||
$this->assertEquals('my_detail_view', Util::fromCamelCase('myDetailView'));
|
||||
$this->assertEquals('my_f_f', Util::fromCamelCase('myFF'));
|
||||
|
||||
$input = array(
|
||||
'detail',
|
||||
'myDetailView',
|
||||
'myFF',
|
||||
);
|
||||
$result = array(
|
||||
'detail',
|
||||
'my_detail_view',
|
||||
'my_f_f',
|
||||
);
|
||||
$this->assertEquals($result, Util::fromCamelCase($input));
|
||||
}
|
||||
|
||||
public function testToUnderScoree()
|
||||
public function testToUnderScore()
|
||||
{
|
||||
$this->assertEquals('detail', Util::toUnderScore('detail'));
|
||||
$this->assertEquals('detail_view', Util::toUnderScore('detailView'));
|
||||
$this->assertEquals('my_detail_view', Util::toUnderScore('myDetailView'));
|
||||
$this->assertEquals('my_f_f', Util::toUnderScore('myFF'));
|
||||
$this->assertEquals('detail', Util::toUnderScore('detail'));
|
||||
$this->assertEquals('detail_view', Util::toUnderScore('detailView'));
|
||||
$this->assertEquals('my_detail_view', Util::toUnderScore('myDetailView'));
|
||||
$this->assertEquals('my_f_f', Util::toUnderScore('myFF'));
|
||||
|
||||
$input = array(
|
||||
'detail',
|
||||
'detailView',
|
||||
'myDetailView',
|
||||
'myFF',
|
||||
);
|
||||
$result = array(
|
||||
'detail',
|
||||
'detail_view',
|
||||
'my_detail_view',
|
||||
'my_f_f',
|
||||
);
|
||||
$this->assertEquals($result, Util::toUnderScore($input));
|
||||
}
|
||||
|
||||
public function testMerge()
|
||||
|
||||
Reference in New Issue
Block a user