Convert camel case to human readable format

@param string $input
@param string $separator
@param bool   $toLower *
@return string
421164
public static function splitCamelCase($input, $separator = '_', $toLower = true): string
    {
        $original = $input;

        $output = preg_replace(['/(?<=[^A-Z])([A-Z])/', '/(?<=[^0-9])([0-9])/'], '_$0', $input);
        $output = preg_replace('#_{1,}#', $separator, $output);

        $output = trim($output);
        if ($toLower) {
            $output = strtolower($output);
        }

        if ('' === $output) {
            return $original;
        }

        return $output;
    }
1011375
public static function camelize($string, $separator = null, $preserveWhiteSpace = false, $isKey = false)
    {
        empty($separator) && $separator = ['_', '-'];

        $_newString = ucwords(str_replace($separator, ' ', $string));

        if (false !== $isKey) {
            $_newString = lcfirst($_newString);
        }

        return (false === $preserveWhiteSpace ? str_replace(' ', null, $_newString) : $_newString);
    }
556143
protected function formatKeyCase($input, $levels = null)
    {
        $caseFormat = APIBoilerplate::getResponseCaseType();

        if ($caseFormat == APIBoilerplate::CAMEL_CASE) {
            if (is_array($input)) {
                $transformed = camel_case_array_keys($input, $levels);
            } else {
                $transformed = camel_case($input);
            }
        } elseif ($caseFormat == APIBoilerplate::SNAKE_CASE) {
            if (is_array($input)) {
                $transformed = snake_case_array_keys($input, $levels);
            } else {
                $transformed = snake_case($input);
            }
        }

        return $transformed;
    }
234164
public static function toUnderscoreVariable($input)
	{
	    // from camel case to the underscores separated lower string.
	    $input = self::fromCamelCase($input, false);
	    $input = strtolower(self::toUnderscoreSeparated($input));
	    $input = str_replace('\\_', '\\', str_replace('/_', '/', $input));
	    return $input;
	}
1350446
public static function camelify( string $name, $separator = '.' ): string {

    // preprocess the separator and the name inputs
    $separator = is_array( $separator ) ? $separator : [ $separator ];
    foreach( $separator as &$tmp ) {

      $tmp  = $tmp{0};
      $name = preg_replace( '/\\' . preg_quote( $tmp, '/' ) . '+/i', $tmp, trim( $name, $tmp ) );
    }

    // create the new name
    $return = '';
    for( $i = 0, $length = mb_strlen( $name ); $i < $length; ++$i ) {
      if( in_array( $name{$i}, $separator ) ) $return .= mb_strtoupper( $name{++$i} );
      else $return .= $name{$i};
    }

    return $return;
  }
421882
public static function ucFirst($input): string
    {
        $string = Str::low($input);
        $string = ucfirst($string);

        return $string;
    }
1036393
public static function toStudlyCase($input) {
		$input = trim($input, '-_');
		return ucfirst(preg_replace_callback('/([A-Z-_][a-z]+)/', function($matches) {
			return ucfirst(str_replace(['-','_'], '',$matches[0]));
		}, $input));
	}
1109515
public static function camelToSeparator(string $camelCaseString, string $separator = '_'): string
    {
        $separatedString = preg_replace('/([a-zA-Z])([A-Z])/', '$1' . $separator . '$2', $camelCaseString);
        $separatedString = preg_replace('/([A-Z0-9])([A-Z])/', '$1' . $separator . '$2', $separatedString);

        return strtolower($separatedString);
    }
925133
protected function convertToSnakeCase($input)
    {
        if ($this->convertToSnakeCaseIsDisabled()) {
            return;
        }

        if (is_null($input)) {
            return null;
        } elseif (is_array($input)) {
            return $this->convertArrayToSnakeCase($input);
        }

        return snake_case($input);
    }
472564
public function getBuffer($trim = "", $tolower = false)
		{
		$r = $this->buffer;
		if ($trim)
			{
			$r = trim($r, " \t\n\r\0\x0B" . $trim);
			}
		if ($tolower)
			{
			$r = strtolower($r);
			}
		return $r;
		}
1258277
public static function toCamelCase($str, $firstInLowerCase = false)
    {
        $str = str_replace(" ", "", ucwords(str_replace("_", " ", $str)));
        return $firstInLowerCase ? lcfirst($str) : $str;
    }
904698
public static function toUnderScoreCase($name, $toLower = true)
    {
        $result = trim(preg_replace('/[A-Z]/', '_\0', $name), '_');
        if($toLower)
        {
            $result = strtolower($result);
        }
        return $result;
    }
92277
private function implode($value, $separator = '|'): string
    {
        if (is_string($value)) {
            return $value;
        }

        if (is_array($value) && count($value) === 1) {
            return reset($value);
        }

        return sprintf('(%s)', collect($value)->implode($separator));
    }
637726
@SneakyThrows
   public static List<String> split(CharSequence input, char separator) {
      if (input == null) {
         return new ArrayList<>();
      }
      Preconditions.checkArgument(separator != '"', "Separator cannot be a quote");
      try (CSVReader reader = CSV.builder().delimiter(separator).reader(new StringReader(input.toString()))) {
         List<String> all = new ArrayList<>();
         List<String> row;
         while ((row = reader.nextRow()) != null) {
            all.addAll(row);
         }
         return all;
      }
   }
1164553
public static function fromCamelCaseToLower($word, string $separator = '-'): string
    {
        $str = '';
        $active = false;
        $word = (string) $word;
        for ($i = 0; $i <= mb_strlen($word); $i++) {
            $char = mb_substr($word, $i, 1, self::ENCODING);
            $str .= ($active && $char >= 'A' && $char <= 'Z' ? $separator : '') . mb_strtolower($char);
            $active = $char !== ' ';
        }
        return $str;
    }
1363512
public function substringBeforeFirst($separator)
    {
        if (($offset = $this->indexOf($separator)) === false) {
            return false;
        }

        return static::create(mb_substr($this->str, 0, $offset, $this->encoding), $this->encoding);
    }
994287
public static function kebabCase(string $input): string
    {
        $words = __::words(preg_replace("/['\x{2019}]/u", '', $input));

        return array_reduce(
            $words,
            function ($result, $word) use ($words) {
                $isFirst = __::first($words) === $word;

                return $result . (!$isFirst ? '-' : '') . __::toLower($word);
            },
            ''
        );
    }