keboola/php-utils

View on GitHub
src/Keboola/Utils/camelize.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace Keboola\Utils;

/**
 * @param $string
 * @param bool $ucfirst
 * @return mixed|string
 */
function camelize($string, $ucfirst = false)
{
    $string = str_replace(["_", "-"], " ", $string);
    $string = ucwords($string);
    $string = str_replace(" ", "", $string);
    return $ucfirst ? $string : lcfirst($string);
}