<?php


namespace AutoAdmin\Bundle\Core\Util;


class CaseConverter
{
    public function kebabToCamelCase($string, $capitalizeFirstCharacter = false): string
    {
        $str = str_replace('-', '', ucwords($string, '-'));

        if (!$capitalizeFirstCharacter) {
            $str = lcfirst($str);
        }

        return $str;
    }

    public function snakeToCamelCase($string, $capitalizeFirstCharacter = false): string
    {
        $str = str_replace('_', '', ucwords($string, '_'));

        if (!$capitalizeFirstCharacter) {
            $str = lcfirst($str);
        }

        return $str;
    }

    public function camelToKebabCase($string)
    {
        return trim(strtolower(preg_replace('%([A-Z])([a-z])%', '-\1\2', $string)), '-');
    }

    public function camelToSnakeCase($string)
    {
        return trim(strtolower(preg_replace('%([A-Z])([a-z])%', '_\1\2', $string)), '_');
    }
}