public static splitCamel ( string $text ) : string | ||
$text | string | |
Résultat | string |
public static function splitCamel($text)
{
$pattern = '/(?<=[a-z])(?=[A-Z])/x';
$segments = preg_split($pattern, $text);
return strtolower(join($segments, ' '));
}
public function testSplitCamel() { $this->assertEquals('thirty seven', Utils::splitCamel('thirtySeven')); $this->assertEquals('one thousand and five hundred sixty three', Utils::splitCamel('oneThousandAndFiveHundredSixtyThree')); $this->assertEquals('seven hundred eighty five', Utils::splitCamel('sevenHundredEightyFive')); }