<?php
$data = [
'MY_TABLE' => 'MyTable',
'MyTable' => 'MyTable',
'my_table' => 'MyTable',
'myTable' => 'MyTable',
];
function yiiCamelize($word) {
return str_replace(' ', '', ucwords(preg_replace('/[^\pL\pN]+/u', ' ', $word)));
}
function camelCaseIt($input)
{
return strtr(ucwords(implode(' ', explode('_', strtolower(strtr(yiiCamelize($input), [' ' => '_']))))), [' ' => '']);
}
foreach ($data as $input => $expected) {
$actual = camelCaseIt($input);
if ($actual === $expected) {
echo '.';
} else {
echo 'F(' . $actual . ')';
}
}
preferences:
65.32 ms | 402 KiB | 5 Q