An open API service indexing awesome lists of open source software.

https://github.com/alexskrypnyk/str2name

Convert strings to named formats
https://github.com/alexskrypnyk/str2name

camelcase converter formatter pascalcase php snakecase string unicode

Last synced: 3 months ago
JSON representation

Convert strings to named formats

Awesome Lists containing this project

README

        



Str2Name logo

Convert strings to named formats

[![GitHub Issues](https://img.shields.io/github/issues/AlexSkrypnyk/str2name.svg)](https://github.com/AlexSkrypnyk/str2name/issues)
[![GitHub Pull Requests](https://img.shields.io/github/issues-pr/AlexSkrypnyk/str2name.svg)](https://github.com/AlexSkrypnyk/str2name/pulls)
[![Test PHP](https://github.com/AlexSkrypnyk/str2name/actions/workflows/test-php.yml/badge.svg)](https://github.com/AlexSkrypnyk/str2name/actions/workflows/test-php.yml)
[![codecov](https://codecov.io/gh/AlexSkrypnyk/str2name/graph/badge.svg?token=7WEB1IXBYT)](https://codecov.io/gh/AlexSkrypnyk/str2name)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/AlexSkrypnyk/str2name)
![LICENSE](https://img.shields.io/github/license/AlexSkrypnyk/str2name)
![Renovate](https://img.shields.io/badge/renovate-enabled-green?logo=renovatebot)

---

## Installation and usage

`Str2Name` is a self-contained class that can be included in any PHP
project directly or via Composer. It does not have any dependencies.

There are two ways to include `Str2Name` in your project:

- [Direct download](#direct-download)
- [Composer](#composer)

### Direct download

1. Download the file from
the [releases page](https://github.com/AlexSkrypnyk/str2name/releases)

2. Register the namespace in `composer.json` of your project:

```composer.json
{
"autoload": {
"psr-4": {
"AlexSkrypnyk\\Str2Name\\": "path/to/src/Str2Name.php"
}
}
}
```

3. Use it in your project:

```php
`i_am_a__string_with_sp@ce¥s_14_and_😀_unicode_élève` |
| `camel` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`iAmAStringWithSp@ce¥s14And😀UnicodeÉlève` |
| `pascal` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`IAmAStringWithSp@ce¥s14And😀UnicodeÉlève` |
| `kebab` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`i-am-a--string-with-sp@ce¥s-14-and-😀-unicode-élève` |
| `train` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`I-Am-A--String-With-Sp@ce¥s-14-And-😀-Unicode-Élève` |
| `flat` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`iamastringwithsp@ce¥s14and😀unicodeélève` |
| `cobol` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`I-AM-A--STRING-WITH-SP@CE¥S-14-AND-😀-UNICODE-ÉLÈVE` |

## Converters between generic formats

| Method | Conversion|
| --- | --- |
| `snake2camel` | `i_am_a__string_with_sp@ce¥s_14_and_😀_unicode_élève`
`iAmAStringWithSp@ce¥s14And😀UnicodeÉlève` |
| `snake2pascal` | `i_am_a__string_with_sp@ce¥s_14_and_😀_unicode_élève`
`IAmAStringWithSp@ce¥s14And😀UnicodeÉlève` |
| `snake2kebab` | `i_am_a__string_with_sp@ce¥s_14_and_😀_unicode_élève`
`i-am-a--string-with-sp@ce¥s-14-and-😀-unicode-élève` |
| `snake2train` | `i_am_a__string_with_sp@ce¥s_14_and_😀_unicode_élève`
`I-Am-A--String-With-Sp@ce¥s-14-And-😀-Unicode-Élève` |
| `snake2flat` | `i_am_a__string_with_sp@ce¥s_14_and_😀_unicode_élève`
`iamastringwithsp@ce¥s14and😀unicodeélève` |
| `snake2cobol` | `i_am_a__string_with_sp@ce¥s_14_and_😀_unicode_élève`
`I-AM-A--STRING-WITH-SP@CE¥S-14-AND-😀-UNICODE-ÉLÈVE` |
| `camel2snake` | `iAmAStringWithSp@ce¥s14And😀UnicodeÉlève`
`i_am_a_string_with_sp@ce¥s_14_and😀_unicode_élève` |
| `camel2pascal` | `iAmAStringWithSp@ce¥s14And😀UnicodeÉlève`
`IAmAStringWithSp@ce¥s14And😀UnicodeÉlève` |
| `camel2kebab` | `iAmAStringWithSp@ce¥s14And😀UnicodeÉlève`
`i-am-a-string-with-sp@ce¥s-14-and😀-unicode-élève` |
| `camel2train` | `iAmAStringWithSp@ce¥s14And😀UnicodeÉlève`
`I-Am-A-String-With-Sp@ce¥s-14-And😀-Unicode-Élève` |
| `camel2flat` | `iAmAStringWithSp@ce¥s14And😀UnicodeÉlève`
`iamastringwithsp@ce¥s14and😀unicodeélève` |
| `camel2cobol` | `iAmAStringWithSp@ce¥s14And😀UnicodeÉlève`
`I-AM-A-STRING-WITH-SP@CE¥S-14-AND😀-UNICODE-ÉLÈVE` |
| `pascal2snake` | `IAmAStringWithSp@ce¥s14And😀UnicodeÉlève`
`i_am_a_string_with_sp@ce¥s_14_and😀_unicode_élève` |
| `pascal2camel` | `IAmAStringWithSp@ce¥s14And😀UnicodeÉlève`
`iAmAStringWithSp@ce¥s14And😀UnicodeÉlève` |
| `pascal2kebab` | `IAmAStringWithSp@ce¥s14And😀UnicodeÉlève`
`i-am-a-string-with-sp@ce¥s-14-and😀-unicode-élève` |
| `pascal2train` | `IAmAStringWithSp@ce¥s14And😀UnicodeÉlève`
`I-Am-A-String-With-Sp@ce¥s-14-And😀-Unicode-Élève` |
| `pascal2flat` | `IAmAStringWithSp@ce¥s14And😀UnicodeÉlève`
`iamastringwithsp@ce¥s14and😀unicodeélève` |
| `pascal2cobol` | `IAmAStringWithSp@ce¥s14And😀UnicodeÉlève`
`I-AM-A-STRING-WITH-SP@CE¥S-14-AND😀-UNICODE-ÉLÈVE` |
| `kebab2snake` | `i-am-a--string-with-sp@ce¥s-14-and-😀-unicode-élève`
`i_am_a__string_with_sp@ce¥s_14_and_😀_unicode_élève` |
| `kebab2camel` | `i-am-a--string-with-sp@ce¥s-14-and-😀-unicode-élève`
`iAmAStringWithSp@ce¥s14And😀UnicodeÉlève` |
| `kebab2pascal` | `i-am-a--string-with-sp@ce¥s-14-and-😀-unicode-élève`
`IAmAStringWithSp@ce¥s14And😀UnicodeÉlève` |
| `kebab2train` | `i-am-a--string-with-sp@ce¥s-14-and-😀-unicode-élève`
`I-Am-A--String-With-Sp@ce¥s-14-And-😀-Unicode-Élève` |
| `kebab2flat` | `i-am-a--string-with-sp@ce¥s-14-and-😀-unicode-élève`
`iamastringwithsp@ce¥s14and😀unicodeélève` |
| `kebab2cobol` | `i-am-a--string-with-sp@ce¥s-14-and-😀-unicode-élève`
`I-AM-A--STRING-WITH-SP@CE¥S-14-AND-😀-UNICODE-ÉLÈVE` |
| `train2snake` | `I-Am-A--String-With-Sp@ce¥s-14-And-😀-Unicode-Élève`
`i_am_a__string_with_sp@ce¥s_14_and_😀_unicode_élève` |
| `train2camel` | `I-Am-A--String-With-Sp@ce¥s-14-And-😀-Unicode-Élève`
`iAmAStringWithSp@ce¥s14And😀UnicodeÉlève` |
| `train2pascal` | `I-Am-A--String-With-Sp@ce¥s-14-And-😀-Unicode-Élève`
`IAmAStringWithSp@ce¥s14And😀UnicodeÉlève` |
| `train2kebab` | `I-Am-A--String-With-Sp@ce¥s-14-And-😀-Unicode-Élève`
`i-am-a--string-with-sp@ce¥s-14-and-😀-unicode-élève` |
| `train2flat` | `I-Am-A--String-With-Sp@ce¥s-14-And-😀-Unicode-Élève`
`iamastringwithsp@ce¥s14and😀unicodeélève` |
| `train2cobol` | `I-Am-A--String-With-Sp@ce¥s-14-And-😀-Unicode-Élève`
`I-AM-A--STRING-WITH-SP@CE¥S-14-AND-😀-UNICODE-ÉLÈVE` |
| `cobol2snake` | `I-AM-A--STRING-WITH-SP@CE¥S-14-AND-😀-UNICODE-ÉLÈVE`
`i_am_a__string_with_sp@ce¥s_14_and_😀_unicode_élève` |
| `cobol2camel` | `I-AM-A--STRING-WITH-SP@CE¥S-14-AND-😀-UNICODE-ÉLÈVE`
`iAmAStringWithSp@ce¥s14And😀UnicodeÉlève` |
| `cobol2pascal` | `I-AM-A--STRING-WITH-SP@CE¥S-14-AND-😀-UNICODE-ÉLÈVE`
`IAmAStringWithSp@ce¥s14And😀UnicodeÉlève` |
| `cobol2kebab` | `I-AM-A--STRING-WITH-SP@CE¥S-14-AND-😀-UNICODE-ÉLÈVE`
`i-am-a--string-with-sp@ce¥s-14-and-😀-unicode-élève` |
| `cobol2train` | `I-AM-A--STRING-WITH-SP@CE¥S-14-AND-😀-UNICODE-ÉLÈVE`
`I-Am-A--String-With-Sp@ce¥s-14-And-😀-Unicode-Élève` |
| `cobol2flat` | `I-AM-A--STRING-WITH-SP@CE¥S-14-AND-😀-UNICODE-ÉLÈVE`
`iamastringwithsp@ce¥s14and😀unicodeélève` |

## Named formatters

| Method | Conversion|
| --- | --- |
| `constant` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`I_AM_A__STRING_WITH_SPCES_14_AND__UNICODE_ELEVE` |
| `constantRaw` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`I_AM_A__STRING_WITH_SP@CE¥S_14_AND_😀_UNICODE_ÉLÈVE` |
| `cssClass` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`i-am-a__string-with-spces-14-and--unicode-eleve` |
| `cssClassRaw` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`I-am-a__string-With-spce¥s-14-and--unicode-élève` |
| `cssId` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`i-am-a-string-with-spces-14-and-unicode-eleve` |
| `cssIdRaw` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`i-am-a-string-with-spces-14-and-unicode-lve` |
| `domain` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`i_am_a__stringwith_sp@ce¥s_14_and_😀_unicode_élève` |
| `httpHeader` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`I-Am-A--String-With-Spces-14-And--Unicode-Eleve` |
| `id` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`iamastringwithspces14andunicodeeleve` |
| `idRaw` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`iamastringwithsp@ce¥s14and😀unicodeélève` |
| `idUpper` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`IAMASTRINGWITHSPCES14ANDUNICODEELEVE` |
| `idUpperRaw` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`IAMASTRINGWITHSP@CE¥S14AND😀UNICODEÉLÈVE` |
| `label` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`I am a string With sp@ce¥s 14 and 😀 unicode élève` |
| `machine` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`i_am_a__string_with_spces_14_and__unicode_eleve` |
| `machineRaw` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`i_am_a__string_with_sp@ce¥s_14_and_😀_unicode_élève` |
| `phpClass` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`IamAStringWithSpces14AndUnicodeEleve` |
| `phpClassRaw` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`IAmAStringWithSp@ce¥s14And😀UnicodeÉlève` |
| `phpFunction` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`i_am_a__string_with_spces_14_and__unicode_eleve` |
| `phpFunctionRaw` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`i_am_a__string_with_sp@ce¥s_14_and_😀_unicode_élève` |
| `phpMethod` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`iAmAStringWithSpces14AndUnicodeEleve` |
| `phpMethodRaw` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`iAmAStringWithSp@ce¥s14And😀UnicodeÉlève` |
| `phpNamespace` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`IAmAStringWithSpces14AndUnicodeEleve` |
| `phpNamespaceRaw` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`IAmAStringWithSp@ce¥s14And😀UnicodeÉlève` |
| `phpPackage` | `I am a__string-W/ith sp@ce¥s 14 and 😀 unicode élève`
`i-am-a__string-w/ith-sp-ce-s-14-and-unicode-l-ve` |
| `phpPackageName` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`i-am-a__string-with-sp-ce-s-14-and-unicode-l-ve` |
| `phpPackageNamespace` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`i-am-a__string-with-sp-ce-s-14-and-unicode-l-ve` |
| `sentence` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève`
`I am a string-with sp@ce¥s 14 and 😀 unicode élève` |

## Maintenance

composer install
composer lint
composer test
composer docs

---
_This repository was created using the [Scaffold](https://getscaffold.dev/) project template_