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

This package is auto-updated.

Last update: 2024-10-15 11:17:47 UTC


README

Contributors Contributors Forks Stargazers Issues MIT License

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.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Top contributors:

contrib.rocks image

License

Distributed under the MIT License. See LICENSE.txt for more information.