splitCamelCase() 공개 정적인 메소드

Convert camel case to human readable format
public static splitCamelCase ( string $input, string $separator = '_', boolean $toLower = true ) : string
$input string
$separator string
$toLower boolean
리턴 string
예제 #1
0
 /**
  * @param null|string $testName
  * @return string
  */
 protected function _getPrefix($testName = null)
 {
     if (null === $testName) {
         $objects = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT);
         foreach ($objects as $object) {
             if (isset($object['object']) && $object['object'] instanceof \PHPUnit_Framework_TestCase) {
                 $testName = $object['class'] . '_' . $object['function'];
                 break;
             }
         }
     }
     $testName = str_replace(__NAMESPACE__ . '\\', '', $testName);
     $testName = Str::splitCamelCase($testName, '_', true);
     $testName = preg_replace('/^test_/', '', $testName);
     $testName = preg_replace('/_test$/', '', $testName);
     $testName = str_replace('_test_test_', '_', $testName);
     $testName = str_replace(array('/', '\\', '_', '-'), '', $testName);
     $testName = strtolower($testName);
     if (!$testName) {
         $testName = uniqid('', true);
         $testName = str_replace('.', '', $testName);
     }
     return $testName;
 }
예제 #2
0
파일: StringTest.php 프로젝트: jbzoo/utils
 public function testSplitCamelCase()
 {
     isSame('_', Str::splitCamelCase('_'));
     isSame('word', Str::splitCamelCase('word'));
     isSame('word_and_word', Str::splitCamelCase('wordAndWord'));
     isSame('word_123_number', Str::splitCamelCase('word123Number'));
     isSame('word number', Str::splitCamelCase('wordNumber', ' '));
     isSame('word Number', Str::splitCamelCase('wordNumber', ' ', false));
     isSame('word_Number', Str::splitCamelCase('wordNumber', '_', false));
     isSame('Word_Number', Str::splitCamelCase('WordNumber', '_', false));
 }