for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Equip\String;
/**
* Convert a snake_case string to a camelCase one.
*
* @param string $snake_string The original snake_case string.
* @param bool $first Whether the first letter should be capitalized
* @return string The converted string.
*/
function snakeToCamelCase($snake_string, $first = false)
{
$camel = implode('', array_map(static function($piece) {
return ucfirst(strtolower($piece));
}, preg_split('/_++/', $snake_string)));
return $first ? $camel : lcfirst($camel);
}