for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace RoadBunch\StringBean;
class SplitCamelCaseFormatter extends AbstractFormatter
{
public function format(string $string): string
$regex = '/(?<=[a-z])(?=[A-Z])|(?<=[A-Z\.])(?=[A-Z][a-z])/x';
$words = preg_split($regex, $string, limit: -1, flags: PREG_SPLIT_NO_EMPTY);
if (!empty($words)) {
return implode(' ', $words);
};
return $string;
}