Skip to content

Instantly share code, notes, and snippets.

@aklump
Created October 10, 2023 01:04
Show Gist options
  • Save aklump/5a6a353d8c8a9e8c08edce25ccdb2616 to your computer and use it in GitHub Desktop.
Save aklump/5a6a353d8c8a9e8c08edce25ccdb2616 to your computer and use it in GitHub Desktop.
class UpperCamel {
public function __invoke(string $value): string {
$value = preg_replace('/[\s\-_]/s', ' ', $value);
$value = trim(preg_replace('/[A-Z]/', ' \0', $value));
$value = preg_replace('/(\s)\s+/s', '\1', $value);
$value = ucwords($value);
$value = preg_replace('/\s+/s', '', $value);
return $value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment