PHP Classes
elePHPant
Icontem

PHP Case Convert: Convert strings between many naming conventions

Recommend this page to a friend!

  Author Author  
Name: jawira <contact>
Classes: 4 packages by
Country: Belgium Belgium
Innovation award
Innovation award
Nominee: 1x


  Detailed description   Download Download .zip .tar.gz  
This package can be used to convert strings between many naming conventions.

It provides a base class for performing the conversion of the case of words used in a string. Then it provides several sub-classes that can perform the actual case conversion. Currently it provides sub-classes for converting strings using the following naming conventions:

- Snake case
- Camel case
- Kebab case
- Pascal case
- Ada case
- Train case
- Cobol case
- Macro case
- Upper case
- Lower case
- Title case
- Sentence case
- Dot notation

Details

Case converter

Use this library to convert string between:

| Name | Method | Output example | | ------------- | --------------- | ----------------- | | ? Camel case | toCamel() | myNameIsBond | | ??? Pascal case | toPascal() | MyNameIsBond | | ? Snake case | toSnake() | my_name_is_bond | | ??? Ada case | toAda() | My_Name_Is_Bond | | ?? Macro case | toMacro() | MY_NAME_IS_BOND | | ? Kebab case | toKebab() | my-name-is-bond | | ? Train case | toTrain() | My-Name-Is-Bond | | ? Cobol case | toCobol() | MY-NAME-IS-BOND | | ? Lower case | toLower() | my name is bond | | ? Upper case | toUpper() | MY NAME IS BOND | | ? Title case | toTitle() | My Name Is Bond | | ?? Sentence case | toSentence() | My name is bond | | ?? Dot notation | toDot() | my.name.is.bond |

Features:

  • ? [automatic case detection][detection algorithm]
  • ? [factory][]
  • ? i18n

Latest Stable Version PHP from Packagist Build Status Maintainability Test Coverage Total Downloads Monthly Downloads Daily Downloads PHPPackages Rank PHPPackages Referenced By Average time to resolve an issue Percentage of issues still open License composer.lock PDS Skeleton Issues

Usage

Input string (i.e. _john-connor_) format is going to be [detected automatically][detection algorithm]. Here's an example:

use Jawira\CaseConverter\Convert;

$hero = new Convert('john-connor');

echo $hero->toCamel();   // output: johnConnor

Of course you can explicitly set the format of input string:

echo $hero->fromKebab()->toSnake();   // output: john_connor

You can also use the [provided factory][factory] to instantiate Convert class. A list of [all public methods] is also available.

i18n

Fully compatible with non-english alphabets:

// Spanish
$esp = new Convert('DON_RAMÓN_Y_ÑOÑO');
echo $esp->toCamel();   // output: donRamónYÑoño

// Greek
$grc = new Convert('????-????');
echo $grc->toCamel();   // output: ????????

// Russian
$rus = new Convert('?????_???????');
echo $rus->toCamel();   // output: ????????????

case-converter is compatible with _Simple Case-Mapping_ and _Full Case-Mapping_. [Learn more about Case-Mapping][Case-Mapping].

Installation

$ composer require jawira/case-converter

Documentation

<https://jawira.github.io/case-converter/>

Contributing

If you liked this project, ? star it on [GitHub].

License

This library is licensed under the [MIT LICENSE].

<!--mkdocs: Do not use relative path for links and images-->

[all public methods]: https://jawira.github.io/case-converter/api.html [CONTRIBUTING.md]: https://jawira.github.io/case-converter/contributing.html [Countable interface]: https://php.net/manual/en/class.countable.php [Case-Mapping]: https://jawira.github.io/case-converter/case-mapping.html [magic method]: https://www.php.net/manual/en/language.oop5.magic.php#object.tostring [MIT LICENSE]: https://jawira.github.io/case-converter/license.html [open an issue]: https://github.com/jawira/case-converter/issues/new [detection algorithm]: https://jawira.github.io/case-converter/detection-algorithm.html [factory]: https://jawira.github.io/case-converter/using-the-factory.html [GitHub]: https://github.com/jawira/case-converter/

*

Packages from jawira

<dl>

<dt><a href="https://packagist.org/packages/jawira/emoji-catalog">jawira/emoji-catalog</a> (library)</dt> <dd>Get access to +3000 emojis as class constants.</dd>

<dt><a href="https://packagist.org/packages/jawira/phing-visualizer">jawira/phing-visualizer</a> (library)</dt> <dd>Graphical representation of Phing's buildfile.</dd>

<dt><a href="https://packagist.org/packages/jawira/phing-open-task">jawira/phing-open-task</a> (library)</dt> <dd>Phing task to open files, directories, and URLs with your favorite software.</dd>

<dt><a href="https://packagist.org/packages/jawira/">more...</a></dt> </dl>


  Classes of jawira  >  PHP Case Convert  >  Download Download .zip .tar.gz  >  Support forum Support forum  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  

 

Name: PHP Case Convert
Base name: case-converter
Description: Convert strings between many naming conventions
Version: -
PHP version: 5
License: Custom (specified in a license file)
 
  Groups   Applications   Files Files  

  Groups  
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes
Group folder image Text processing Manipulating and validating text data View top rated classes


  Applications that use this package  
No pages of applications that use this class were specified.

Add link image If you know an application of this package, send a message to the author to add a link here.

  Files folder image Files  
File Role Description
Files folder image.idea (1 file, 1 directory)
Files folder imageconfig (2 files)
Files folder imagedocs (8 files, 1 directory)
Files folder imagesrc (4 files, 2 directories)
Files folder imagetests (2 directories)
Accessible without login Plain text file .codeclimate.yml Data Auxiliary data
Accessible without login Plain text file .editorconfig Data Auxiliary data
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file build.xml Data Auxiliary data
Accessible without login Plain text file CHANGELOG.md Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file CONTRIBUTING.md Data Auxiliary data
Accessible without login Plain text file LICENSE.md Lic. License text
Accessible without login Plain text file mkdocs.yml Data Auxiliary data
Accessible without login Plain text file phive.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  .idea  
File Role Description
Files folder imagedictionaries (1 file)
  Accessible without login Plain text file phing.xml Data Auxiliary data

  Files folder image Files  /  .idea  /  dictionaries  
File Role Description
  Accessible without login Plain text file jawira.xml Data Auxiliary data

  Files folder image Files  /  config  
File Role Description
  Accessible without login Plain text file behat.yml Data Auxiliary data
  Accessible without login Plain text file phpunit.xml Data Auxiliary data

  Files folder image Files  /  docs  
File Role Description
Files folder imageimages (6 files)
  Accessible without login Plain text file api.md Data Auxiliary data
  Accessible without login Plain text file case-mapping.md Data Auxiliary data
  Accessible without login Plain text file detection-algorithm.md Data Auxiliary data
  Accessible without login Plain text file dev.md Data Auxiliary data
  Accessible without login Plain text file examples.md Example Example script
  Accessible without login Plain text file known-issues.md Data Auxiliary data
  Accessible without login Plain text file naming-conventions.md Data Auxiliary data
  Plain text file using-the-factory.md Class Class source

  Files folder image Files  /  docs  /  images  
File Role Description
  Accessible without login Plain text file build.puml Data Auxiliary data
  Accessible without login Plain text file detection-algorithm.puml Data Auxiliary data
  Accessible without login Plain text file number-problem.puml Data Auxiliary data
  Accessible without login Plain text file uml-case-converter.puml Data Auxiliary data
  Accessible without login Plain text file uml-glue.puml Data Auxiliary data
  Accessible without login Plain text file uml-split.puml Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imageGlue (18 files)
Files folder imageSplit (6 files)
  Plain text file CaseConverter.php Class Class source
  Plain text file CaseConverterException.php Class Class source
  Plain text file CaseConverterInterface.php Class Class source
  Plain text file Convert.php Class Class source

  Files folder image Files  /  src  /  Glue  
File Role Description
  Plain text file AdaCase.php Class Class source
  Plain text file CamelCase.php Class Class source
  Plain text file CobolCase.php Class Class source
  Plain text file DashGluer.php Class Class source
  Plain text file DotNotation.php Class Class source
  Plain text file Gluer.php Class Class source
  Plain text file KebabCase.php Class Class source
  Plain text file LowerCase.php Class Class source
  Plain text file MacroCase.php Class Class source
  Plain text file PascalCase.php Class Class source
  Plain text file SentenceCase.php Class Class source
  Plain text file SnakeCase.php Class Class source
  Plain text file SpaceGluer.php Class Class source
  Plain text file TitleCase.php Class Class source
  Plain text file TrainCase.php Class Class source
  Plain text file UnderscoreGluer.php Class Class source
  Plain text file UpperCase.php Class Class source
  Plain text file UppercaseGluer.php Class Class source

  Files folder image Files  /  src  /  Split  
File Role Description
  Plain text file DashSplitter.php Class Class source
  Plain text file DotSplitter.php Class Class source
  Plain text file SpaceSplitter.php Class Class source
  Plain text file Splitter.php Class Class source
  Plain text file UnderscoreSplitter.php Class Class source
  Plain text file UppercaseSplitter.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imagebehat (1 file, 1 directory)
Files folder imagephpunit (22 files)

  Files folder image Files  /  tests  /  behat  
File Role Description
Files folder imagebootstrap (1 file)
  Accessible without login Plain text file case-converter.feature Data Auxiliary data

  Files folder image Files  /  tests  /  behat  /  bootstrap  
File Role Description
  Plain text file FeatureContext.php Class Class source

  Files folder image Files  /  tests  /  phpunit  
File Role Description
  Plain text file AdaCaseTest.php Class Class source
  Plain text file CamelCaseTest.php Class Class source
  Plain text file CaseConverterTest.php Class Class source
  Plain text file CobolCaseTest.php Class Class source
  Plain text file ConvertTest.php Class Class source
  Plain text file DashSplitterTest.php Class Class source
  Plain text file DotNotationTest.php Class Class source
  Plain text file DotSplitterTest.php Class Class source
  Plain text file GluerTest.php Class Class source
  Plain text file KebabCaseTest.php Class Class source
  Plain text file LowerCaseTest.php Class Class source
  Plain text file MacroCaseTest.php Class Class source
  Plain text file PascalCaseTest.php Class Class source
  Plain text file SentenceCaseTest.php Class Class source
  Plain text file SnakeCaseTest.php Class Class source
  Plain text file SpaceSplitterTest.php Class Class source
  Plain text file SplitterTest.php Class Class source
  Plain text file TitleCaseTest.php Class Class source
  Plain text file TrainCaseTest.php Class Class source
  Plain text file UnderscoreSplitterTest.php Class Class source
  Plain text file UppercaseSplitterTest.php Class Class source
  Plain text file UpperCaseTest.php Class Class source

Download Download all files: case-converter.tar.gz case-converter.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.