Skip to content

Commit

Permalink
Added more converters.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk committed May 16, 2024
1 parent 079790e commit b465f28
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 11 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,27 @@
| `kebab` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève` <br/> `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` <br/> `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` <br/> `iamastringwithsp@ce¥s14and😀unicodeélève` |
| `cobol` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève` <br/> `I-AM-A--STRING-WITH-SP@CE¥S-14-AND-😀-UNICODE-ÉLÈVE` |

## Named conversions

| Method | Conversion|
| --- | --- |
| `cobol` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève` <br/> `I-AM-A--STRING-WITH-SP@CE¥S-14-AND-😀-UNICODE-ÉLÈVE` |
| `constant` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève` <br/> `I_AM_A__STRING_WITH_SP@CE¥S_14_AND_😀_UNICODE_ÉLÈVE` |
| `constant` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève` <br/> `I_AM_A__STRING_WITH_SPCES_14_AND__UNICODE_ELEVE` |
| `constantRaw` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève` <br/> `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` <br/> `i-am-a__string-with-spces-14-and--unicode-eleve` |
| `cssClassRaw` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève` <br/> `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` <br/> `i-am-a-string-with-spces-14-and-unicode-eleve` |
| `cssIdRaw` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève` <br/> `i-am-a-string-with-spces-14-and-unicode-lve` |
| `domain` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève` <br/> `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` <br/> `I-Am-A--String-With-Sp@ce¥s-14-And-😀-Unicode-Élève` |
| `id` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève` <br/> `iamastringwithsp@ce¥s14and😀unicodeélève` |
| `idUpper` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève` <br/> `IAMASTRINGWITHSP@CE¥S14AND😀UNICODEÉLÈVE` |
| `httpHeader` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève` <br/> `I-Am-A--String-With-Spces-14-And--Unicode-Eleve` |
| `id` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève` <br/> `iamastringwithspces14andunicodeeleve` |
| `idRaw` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève` <br/> `iamastringwithsp@ce¥s14and😀unicodeélève` |
| `idUpper` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève` <br/> `IAMASTRINGWITHSPCES14ANDUNICODEELEVE` |
| `idUpperRaw` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève` <br/> `IAMASTRINGWITHSP@CE¥S14AND😀UNICODEÉLÈVE` |
| `label` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève` <br/> `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` <br/> `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` <br/> `i_am_a__string_with_spces_14_and__unicode_eleve` |
| `machineRaw` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève` <br/> `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` <br/> `IamAStringWithSpces14AndUnicodeEleve` |
| `phpClassRaw` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève` <br/> `IAmAStringWithSp@ce¥s14And😀UnicodeÉlève` |
| `phpFunction` | `I am a__string-With sp@ce¥s 14 and 😀 unicode élève` <br/> `i_am_a__string_with_spces_14_and__unicode_eleve` |
Expand Down
50 changes: 45 additions & 5 deletions Str2Name.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,36 @@ public static function label(string $string): string {

/**
* @from I am a__string-With sp@ce¥s 14 and 😀 unicode élève
* @to i_am_a__string_with_sp@ce¥s_14_and_😀_unicode_élève
* @to i_am_a__string_with_spces_14_and__unicode_eleve
*/
public static function machine(string $string): string {
$string = static::strict($string);
return static::snake(str_replace(['-'], ' ', $string));
}

/**
* @from I am a__string-With sp@ce¥s 14 and 😀 unicode élève
* @to I_AM_A__STRING_WITH_SP@CE¥S_14_AND_😀_UNICODE_ÉLÈVE
* @to i_am_a__string_with_sp@ce¥s_14_and_😀_unicode_élève
*/
public static function machineRaw(string $string): string {
return static::snake(str_replace(['-'], ' ', $string));
}

/**
* @from I am a__string-With sp@ce¥s 14 and 😀 unicode élève
* @to I_AM_A__STRING_WITH_SPCES_14_AND__UNICODE_ELEVE
*/
public static function constant(string $string): string {
$string = static::strict($string);

return mb_strtoupper(static::snake($string));
}

/**
* @from I am a__string-With sp@ce¥s 14 and 😀 unicode élève
* @to I_AM_A__STRING_WITH_SP@CE¥S_14_AND_😀_UNICODE_ÉLÈVE
*/
public static function constantRaw(string $string): string {
return mb_strtoupper(static::snake($string));
}

Expand Down Expand Up @@ -207,9 +226,10 @@ public static function domain(string $string): string {

/**
* @from I am a__string-With sp@ce¥s 14 and 😀 unicode élève
* @to I-Am-A--String-With-Sp@ce¥s-14-And-😀-Unicode-Élève
* @to I-Am-A--String-With-Spces-14-And--Unicode-Eleve
*/
public static function httpHeader(string $string): string {
$string = static::strict($string);
return static::train($string);
}

Expand Down Expand Up @@ -272,17 +292,37 @@ public static function cssIdRaw(string $string): string {

/**
* @from I am a__string-With sp@ce¥s 14 and 😀 unicode élève
* @to iamastringwithsp@ce¥s14and😀unicodeélève
* @to iamastringwithspces14andunicodeeleve
*/
public static function id(string $string): string {
$string = static::strict($string);

return static::flat($string);
}

/**
* @from I am a__string-With sp@ce¥s 14 and 😀 unicode élève
* @to IAMASTRINGWITHSP@CE¥S14AND😀UNICODEÉLÈVE
* @to iamastringwithsp@ce¥s14and😀unicodeélève
*/
public static function idRaw(string $string): string {
return static::flat($string);
}

/**
* @from I am a__string-With sp@ce¥s 14 and 😀 unicode élève
* @to IAMASTRINGWITHSPCES14ANDUNICODEELEVE
*/
public static function idUpper(string $string): string {
$string = static::strict($string);

return mb_strtoupper(static::flat($string));
}

/**
* @from I am a__string-With sp@ce¥s 14 and 😀 unicode élève
* @to IAMASTRINGWITHSP@CE¥S14AND😀UNICODEÉLÈVE
*/
public static function idUpperRaw(string $string): string {
return mb_strtoupper(static::flat($string));
}

Expand Down
1 change: 1 addition & 0 deletions docs.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

$generic_conversions = [
'camel',
'cobol',
'flat',
'kebab',
'pascal',
Expand Down

0 comments on commit b465f28

Please sign in to comment.