Download the PHP package dev-jeetu/case-converter without Composer
On this page you can find all versions of the php package dev-jeetu/case-converter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dev-jeetu/case-converter
More information about dev-jeetu/case-converter
Files in dev-jeetu/case-converter
Package case-converter
Short Description A comprehensive PHP library for converting between different naming conventions (snake_case, camelCase, PascalCase, kebab-case, etc.)
License MIT
Homepage https://github.com/dev-jeetu/case-converter
Informations about the package case-converter
DevJeetu/CaseConverter
A comprehensive PHP library for converting between different naming conventions. Supports snake_case, camelCase, PascalCase, kebab-case, and many more with proper acronym handling and full Unicode support.
โจ Features
- ๐ 14 different case formats supported
- ๐ Full Unicode support for international characters (Greek, Russian, Arabic, Chinese, Japanese)
- ๐ฏ Smart acronym handling (XML, HTTP, API, etc.) with ASCII-only detection
- ๐ Type-safe enum-based API with full IDE support
- ๐ High performance with optimized algorithms and benchmarking
- ๐งช Comprehensive test coverage (422 tests, 1856 assertions)
- ๐ Fluent API for easy chaining
- ๐ก๏ธ Custom exception classes for better error handling
- ๐ง Zero dependencies - pure PHP implementation
- ๐ฆ PSR-4 autoloading compatible
- ๐ PHP 8.1+ support with strict types
๐ฆ Installation
Install via Composer:
๐ Quick Start
๐ Supported Formats & Aliases
| Format | Example | Method | Enum | Aliases |
|---|---|---|---|---|
| camelCase | userName |
toCamel() |
CaseType::CAMEL |
camel, camelcase, camel_case, lower_camel, lowerCamel |
| PascalCase | UserName |
toPascal() |
CaseType::PASCAL |
pascal, pascalcase, pascal_case, upper_camel, upperCamel, studly |
| snake_case | user_name |
toSnake() |
CaseType::SNAKE |
snake, snake_case, underscore, lower_snake |
| kebab-case | user-name |
toKebab() |
CaseType::KEBAB |
kebab, kebab_case, kebab-case, dash, hyphen, lisp |
| MACRO_CASE | USER_NAME |
toMacro() |
CaseType::MACRO |
macro, macro_case, screamed_snake, screaming_snake, upper_snake, constant |
| Train-Case | User-Name |
toTrain() |
CaseType::TRAIN |
train, train_case, train-case, pascal_kebab, pascal-kebab |
| dot.case | user.name |
toDot() |
CaseType::DOT |
dot, dot_case, dot.case, period |
| lower case | username |
toLower() |
CaseType::LOWER |
lower, lower_case, space, space_case, lower_space |
| UPPER CASE | USERNAME |
toUpper() |
CaseType::UPPER |
upper, upper_case, upper_space |
| Title Case | User Name |
toTitle() |
CaseType::TITLE |
title, title_case, start_case, header |
| path/case | user/name |
toPath() |
CaseType::PATH |
path, path_case, path/case, slash, directory |
| Ada_Case | User_Name |
toAda() |
CaseType::ADA |
ada, ada_case, pascal_snake, upper_snake_case |
| COBOL-CASE | USER-NAME |
toCobol() |
CaseType::COBOL |
cobol, cobol_case, upper_kebab, screaming_kebab |
| Sentence case | User name |
toSentence() |
CaseType::SENTENCE |
sentence, sentence_case, first_upper |
๐ Real-world Examples
API Response Transformation
Database Column to PHP Property Mapping
Configuration Key Transformation
International Content Processing
Class Name Generation
URL Slug Generation
๐ Unicode Support
The library provides full Unicode support for international characters:
๐ง Smart Acronym Handling
The library intelligently handles acronyms and preserves them in appropriate contexts:
๐ฏ Advanced Usage
Type-Safe Enum API
Generic Conversion with Aliases
Format Introspection
Fluent Interface
Individual Converters
๐ก๏ธ Error Handling
The library provides custom exceptions for better error handling:
๐ Performance & Benchmarks
The library is optimized for high performance:
Performance Test Results
- CamelCase conversion: ~0.1ms for 1000 iterations
- SnakeCase conversion: ~0.1ms for 1000 iterations
- Unicode conversion: ~0.2ms for 1000 iterations
- Acronym handling: ~0.1ms for 1000 iterations
- Complex strings: <0.002ms per conversion
- Bulk operations: 1000 conversions in <0.1 seconds
๐งช Testing
Run the comprehensive test suite:
๐ง Development
๐ Requirements
- PHP 8.1 or higher
- No external dependencies
๐ค Contributing
Contributions are welcome!
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests for your changes
- Ensure all tests pass (
composer quality) - Commit your changes (
git commit -am 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ Issues & Support
If you discover any issues or have questions:
- Check existing issues
- Open a new issue with a detailed description
- For security issues, please email directly
๐ License
This project is licensed under the MIT License. Please see LICENSE.md for details.
๐ Acknowledgments
- Inspired by various case conversion libraries across different languages
- Built with modern PHP best practices and type safety
- Comprehensive test coverage ensures reliability
- Community feedback and contributions
๐ Changelog
v0.0.1
- โจ Initial release with full Unicode support for international characters
- ๐งฑ Support for 14 different case formats with a type-safe enum-based API
- ๐ง Comprehensive acronym handling (ASCII-based)
- ๐งช 70+ test cases including Unicode scenarios, with 422 tests and 1856 assertions
- ๐ก๏ธ Custom exception classes for better error handling
- โ๏ธ PHP 8.1+ support
- ๐ Improved code organization and reduced duplication
- โก Includes performance benchmarking tests