ashdevelops / php-case
There is no license information available for the latest version (v1.0.0) of this package.
Composer package to detect case styles from arbitrary strings and convert them to other styles.
v1.0.0
2024-08-14 12:05 UTC
Requires
- ext-ctype: *
README
caseconvert
A simple library for converting arbitrary case style texts to other cases.
Supported cases
- camelCase
- PascalCase
- snake_case
- kebab-case
- dot.case
Getting Started
Prerequisites
- PHP >= 8.1.0
Installation
Get it via composer:
composer require ashdevelops/php-case
Usage
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"
Contributing
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
Top contributors:
License
Distributed under the MIT License. See LICENSE.txt
for more information.