Bug #20359 » 0010985_v2.patch
tests/t3lib/t3lib_div_testcase.php (Arbeitskopie) | ||
---|---|---|
$this->assertEquals('/', $actualEnv{0});
|
||
$this->assertEquals('/', $actualEnv{strlen($actualEnv) - 1});
|
||
}
|
||
/**
|
||
* @test
|
||
* @see t3lib_div::underscoredToUpperCamelCase
|
||
*/
|
||
public function canConvertFromUnderscoredToUpperCamelCase() {
|
||
$this->assertEquals('BlogExample', t3lib_div::underscoredToUpperCamelCase('blog_example'));
|
||
$this->assertEquals('Blogexample', t3lib_div::underscoredToUpperCamelCase('blogexample'));
|
||
}
|
||
/**
|
||
* @test
|
||
* @see t3lib_div::underscoredToLowerCamelCase
|
||
*/
|
||
public function canConvertFromUnderscoredToLowerCamelCase() {
|
||
$this->assertEquals('minimalValue', t3lib_div::underscoredToLowerCamelCase('minimal_value'));
|
||
$this->assertEquals('minimalvalue', t3lib_div::underscoredToLowerCamelCase('minimalvalue'));
|
||
}
|
||
/**
|
||
* @test
|
||
* @see t3lib_div::camelCaseToLowerCaseUnderscored
|
||
*/
|
||
public function canConvertFromCamelCaseToLowerCaseUnderscored() {
|
||
$this->assertEquals('blog_example', t3lib_div::camelCaseToLowerCaseUnderscored('BlogExample'));
|
||
$this->assertEquals('blogexample', t3lib_div::camelCaseToLowerCaseUnderscored('Blogexample'));
|
||
$this->assertEquals('blogexample', t3lib_div::camelCaseToLowerCaseUnderscored('blogexample'));
|
||
$this->assertEquals('minimal_value', t3lib_div::camelCaseToLowerCaseUnderscored('minimalValue'));
|
||
}
|
||
/**
|
||
* @test
|
||
* @see t3lib_div::lcfirst
|
||
*/
|
||
public function canConvertFirstCharacterToBeLowerCase() {
|
||
$this->assertEquals('blogexample', t3lib_div::lcfirst('Blogexample'));
|
||
$this->assertEquals('blogExample', t3lib_div::lcfirst('BlogExample'));
|
||
$this->assertEquals('blogexample', t3lib_div::lcfirst('blogexample'));
|
||
}
|
||
}
|
||
?>
|
t3lib/class.t3lib_div.php (Arbeitskopie) | ||
---|---|---|
return $output;
|
||
}
|
||
/**
|
||
* Returns a given string with underscores as UpperCamelCase.
|
||
* Example: Converts blog_example to BlogExample
|
||
*
|
||
* @param string $string: String to be converted to camel case
|
||
* @return string UpperCamelCasedWord
|
||
*/
|
||
public static function underscoredToUpperCamelCase($string) {
|
||
$upperCamelCase = str_replace(' ', '', ucwords(str_replace('_', ' ', self::strtolower($string))));
|
||
return $upperCamelCase;
|
||
}
|
||
/**
|
||
* Returns a given string with underscores as lowerCamelCase.
|
||
* Example: Converts minimal_value to minimalValue
|
||
*
|
||
* @param string $string: String to be converted to camel case
|
||
* @return string lowerCamelCasedWord
|
||
*/
|
||
public static function underscoredToLowerCamelCase($string) {
|
||
$upperCamelCase = str_replace(' ', '', ucwords(str_replace('_', ' ', self::strtolower($string))));
|
||
$lowerCamelCase = self::lcfirst($upperCamelCase);
|
||
return $lowerCamelCase;
|
||
}
|
||
/**
|
||
* Returns a given CamelCasedString as an lowercase string with underscores.
|
||
* Example: Converts BlogExample to blog_example, and minimalValue to minimal_value
|
||
*
|
||
* @param string $string: String to be converted to lowercase underscore
|
||
* @return string lowercase_and_underscored_string
|
||
*/
|
||
public static function camelCaseToLowerCaseUnderscored($string) {
|
||
return self::strtolower(preg_replace('/(?<=\w)([A-Z])/', '_\\1', $string));
|
||
}
|
||
/**
|
||
* Converts the first char of a string to lowercase if it is a latin character (A-Z).
|
||
* Example: Converts "Hello World" to "hello World"
|
||
*
|
||
* @param string $string: The string to be used to lowercase the first character
|
||
* @return string The string with the first character as lowercase
|
||
*/
|
||
public static function lcfirst($string) {
|
||
return self::strtolower(substr($string, 0, 1)) . substr($string, 1);
|
||
}
|
||
/*************************
|
||
*
|
||
* ARRAY FUNCTIONS
|
- « Previous
- 1
- 2
- Next »