A simple library for converting arbitrary case style texts to other cases.
- camelCase
- PascalCase
- snake_case
- kebab-case
- dot.case
- PHP >= 8.1.0
Get it via composer:
composer require ashdevelops/php-case Detect the case:
<?php
use CaseConverter\CaseDetector;
use CaseConverter\Validators\PascalCaseValidator;
include 'vendor/autoload.php';
$arbitraryString = 'SomeArbitraryString';
$detector = new CaseDetector(new PascalCaseValidator());
echo $detector->detect($arbitraryString)->name; // string(6) "Pascal"Snake case to camel:
<?php
use CaseConverter\CaseType;
use CaseConverter\Converters\CamelCaseConverter;
include 'vendor/autoload.php';
$camelConverter = new CamelCaseConverter();
echo $camelConverter->convert('camel_case', CaseType::Snake); // string(9) "camelCase"Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt for more information.