marcusball/case-helper

Easily convert between camelCase, PascalCase, kebab-case, snake_case, SCREAMING_SNAKE_CASE, Train-Case, and string case!

Maintainers

👁 marcusball

Package info

github.com/marcusball/case-helper

pkg:composer/marcusball/case-helper

Statistics

Installs: 52 312

Dependents: 4

Suggesters: 0

Stars: 21

Open Issues: 0

0.2.0 2021-07-14 21:20 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT c5c6321d7f908fce6d77f13b0c0d706cbd880e00

This package is auto-updated.

Last update: 2026-06-05 05:31:46 UTC


README

Easily convert between camelCase, PascalCase, kebab-case, snake_case, SCREAMING_SNAKE_CASE, Train-Case, and string case!

Note about fork

The original package, nabil1337/case-helper, has been abandoned and this repo has taken over ownership.

How to use

use CaseHelper\CaseHelperFactory;

$ch = CaseHelperFactory::make(CaseHelperFactory::INPUT_TYPE_CAMEL_CASE);

$ch->toPascalCase('myStr');

// => returns 'MyStr'

You need to specify which type your input has when calling the factories' make()-method. To do that, use one of the following constants:

  • CaseHelperFactory::INPUT_TYPE_SPACE_CASE for space case
  • CaseHelperFactory::INPUT_TYPE_CAMEL_CASE for camelCase
  • CaseHelperFactory::INPUT_TYPE_PASCAL_CASE for PascalCase
  • CaseHelperFactory::INPUT_TYPE_KEBAB_CASE for kebab-case
  • CaseHelperFactory::INPUT_TYPE_SNAKE_CASE for snake_case
  • CaseHelperFactory::INPUT_TYPE_SCREAMING_SNAKE_CASE for SCREAMING_SNAKE_CASE
  • CaseHelperFactory::INPUT_TYPE_TRAIN_CASE for Train-Case

Twig

Want to use it with Twig? Check out this great example.

Tests

This project was mainly (although not completely) written using TDD. Tests can be run using phpunit.

Contributing

If you want to contribute, please follow the used standards and add or extend tests.