ptrkcsk / change-case
This package is abandoned and no longer maintained.
The author suggests using the jawira/case-converter package instead.
Convert strings to camelCase, CONSTANT_CASE, dot.case, Header-Case, lower case, param-case, PascalCase, path/case, Sentence case, snake_case, Title Case, UPPER CASE, and more!
v0.1.0
2018-08-13 15:19 UTC
Requires
- php: >=7
Requires (Dev)
- phpdocumentor/phpdocumentor: ^2.9
- phpunit/phpunit: ^7.0
This package is not auto-updated.
Last update: 2021-12-28 17:44:56 UTC
README
Convert strings to camelCase
, CONSTANT_CASE
, dot.case
, Header-Case
,
lower case
, param-case
, PascalCase
, path/case
, Sentence case
,
snake_case
, Title Case
, UPPER CASE
, and more!
Change Case is a port to PHP from JavaScript of Blake Embrey’s project of the same name.
Installation
$ composer require ptrkcsk/change-case
Case styles
Style (& aliases) | Example |
---|---|
Camel, lower camel | test string → testString |
Constant, screaming snake | test string → TEST_STRING |
Dot | test string → test.string |
Header | test string → Test-String |
Lower | test string → test string |
Lower first | TEST STRING → tEST STRING |
No | test string → test string |
Param, kebab, lisp | test string → test-string |
Pascal, upper camel | test string → TestString |
Path | test string → test/string |
Sentence | test string → Test string |
Snake, pothole | test string → test_string |
Swap | TeSt StRiNg → tEsT sTrInG |
Title, start | test string → Test String |
Upper, all caps | test string → TEST STRING |
Upper first | test string → Test string |
API Methods
Camel case, lower camel case: test string
→ testString
use ChangeCase\ChangeCase; ChangeCase::camel('test string'); // 'testString' ChangeCase::lowerCamel('test string'); // 'testString'
Constant case, screaming snake case: test string
→ TEST_STRING
use ChangeCase\ChangeCase; ChangeCase::constant('test string'); // 'TEST_STRING' ChangeCase::screamingSnake('test string'); // 'TEST_STRING'
Dot case: test string
→ test.string
use ChangeCase\ChangeCase; ChangeCase::dot('test string'); // 'test.case'
Header case: test string
→ Test-String
use ChangeCase\ChangeCase; ChangeCase::header('test string'); // 'Test-String'
Lower case: test string
→ test string
use ChangeCase\ChangeCase; ChangeCase::lower('test string'); // 'test string'
Lower case first: TEST STRING
→ tEST STRING
use ChangeCase\ChangeCase; ChangeCase::lowerFirst('TEST STRING'); // 'tEST STRING'
No case: test string
→ test string
use ChangeCase\ChangeCase; ChangeCase::no('test string'); // 'test string'
Param case, kebab case, lisp case: test string
→ test-string
use ChangeCase\ChangeCase; ChangeCase::param('test string'); // 'test-string' ChangeCase::kebab('test string'); // 'test-string' ChangeCase::lisp('test string'); // 'test-string'
Pascal case, upper camel case: test string
→ TestString
use ChangeCase\ChangeCase; ChangeCase::pascal('test string'); // 'TestString' ChangeCase::upperCamel('test string'); // 'TestString'
Path case: test string
→ test/string
use ChangeCase\ChangeCase; ChangeCase::path('test string'); // 'test/string'
Sentence case: test string
→ Test string
use ChangeCase\ChangeCase; ChangeCase::sentence('test string'); // 'Test string'
Snake case, pothole case: test string
→ test_string
use ChangeCase\ChangeCase; ChangeCase::snake('test string'); // 'test_string' ChangeCase::pothole('test string'); // 'test_string'
Swap case: TeSt StRiNg
→ tEsT sTrInG
use ChangeCase\ChangeCase; ChangeCase::swap('TeSt StRiNg'); // 'tEsT sTrInG'
Title case, start case: test string
→ Test String
use ChangeCase\ChangeCase; ChangeCase::title('test string'); // 'Test String' ChangeCase::start('test string'); // 'Test String'
Upper case, all caps: test string
→ TEST STRING
use ChangeCase\ChangeCase; ChangeCase::upper('test string'); // 'TEST STRING' ChangeCase::allCaps('test string'); // 'TEST STRING'
Upper case first: test string
→ Test string
use ChangeCase\ChangeCase; ChangeCase::upperFirst('test string'); // 'Test string'