joachim-n/case-converter

There is no license information available for the latest version (1.0.1) of this package.

Case converter library

1.0.1 2023-10-18 14:01 UTC

This package is auto-updated.

Last update: 2024-04-18 15:25:39 UTC


README

Case Converter is a small library for converting strings from one case to another. It handles, as both input and output:

  • camelCase
  • PascalCase
  • snake_case
  • kebab-case
  • Title Case

Installation:

With Composer:

$ composer require joachim-n/case-converter

Usage:

$output = \CaseConverter\CaseString::INPUTFORMAT('MyString')->OUTPUTFORMAT();

For example:

$output = \CaseConverter\CaseString::camel('MyString')->pascal();
$output = \CaseConverter\CaseString::camel('MyString')->snake();
$output = \CaseConverter\CaseString::camel('MyString')->kebab();
$output = \CaseConverter\CaseString::snake('my_string')->camel();
$output = \CaseConverter\CaseString::snake('my_string')->pascal();
$output = \CaseConverter\CaseString::snake('my_string')->kebab();

If your input string is in a format that requires custom splitting, you can pass the pieces to StringAssembler for output. For example:

$output = (new \CaseConverter\StringAssembler(['my', 'string']))->camel();