PHPackages                             ykw/cruet - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ykw/cruet

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ykw/cruet
=========

PHP port of the Rust cruet library case conversion functions. Provides camelCase, snake\_case, kebab-case, PascalCase and other case transformations.

v1.0.0(8mo ago)00MITPHPPHP ^8.4CI passing

Since Sep 3Pushed 8mo agoCompare

[ Source](https://github.com/yankewei/cruet)[ Packagist](https://packagist.org/packages/ykw/cruet)[ RSS](/packages/ykw-cruet/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

PHP Cruet
=========

[](#php-cruet)

[![CI](https://github.com/yankewei/cruet-php/workflows/CI/badge.svg)](https://github.com/yankewei/cruet-php/actions)[![PHP Version](https://camo.githubusercontent.com/504ead6a583c68d8d62d7bfceed24e569ca613d7a36bed380281b3455b5c7b31/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e342d626c7565)](https://www.php.net/)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![codecov](https://camo.githubusercontent.com/848598b0d42241c3da4e672308849090836b290b9f7a1f358db8ffccab45f11f/68747470733a2f2f636f6465636f762e696f2f67682f79616e6b657765692f63727565742d7068702f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://codecov.io/gh/yankewei/cruet-php)

A fast, lightweight PHP library for string case conversions, based on the [Rust cruet library](https://github.com/chrislearn/cruet).

Provides clean, efficient case conversions with a simple API.

Features
--------

[](#features)

- **5 Case Conversions**: camelCase, PascalCase, snake\_case, SCREAMING\_SNAKE\_CASE, kebab-case
- **Format Detection**: Identify string formats programmatically
- **Fluent Interface**: Chain operations for complex transformations
- **High Performance**: Character-by-character processing with intelligent boundary detection
- **No Dependencies**: Pure PHP implementation, no external libraries required

Installation
------------

[](#installation)

```
composer require ykw/cruet
```

Or add to your `composer.json`:

```
{
    "require": {
        "ykw/cruet": "^1.0"
    }
}
```

Quick Start
-----------

[](#quick-start)

```
use Ykw\Cruet\Inflector;

// Case conversions
echo Inflector::toCamelCase('user_account');         // userAccount
echo Inflector::toPascalCase('user_account');        // UserAccount
echo Inflector::toSnakeCase('UserAccount');          // user_account
echo Inflector::toScreamingSnakeCase('UserAccount'); // USER_ACCOUNT
echo Inflector::toKebabCase('UserAccount');          // user-account

// Format detection
var_dump(Inflector::isCamelCase('userAccount'));     // true
var_dump(Inflector::isPascalCase('UserAccount'));    // true
var_dump(Inflector::isSnakeCase('user_account'));    // true

// Fluent interface
$result = Inflector::convert('user_account')
    ->pascalCase()      // UserAccount
    ->snakeCase()       // user_account
    ->screamingSnakeCase() // USER_ACCOUNT
    ->get();
echo $result; // USER_ACCOUNT
```

Usage Examples
--------------

[](#usage-examples)

### Case Conversions

[](#case-conversions)

```
use Ykw\Cruet\Inflector;

$input = 'user_profile_settings';

// All available case conversions
echo Inflector::toCamelCase($input);           // userProfileSettings
echo Inflector::toPascalCase($input);          // UserProfileSettings
echo Inflector::toSnakeCase($input);           // user_profile_settings
echo Inflector::toScreamingSnakeCase($input);  // USER_PROFILE_SETTINGS
echo Inflector::toKebabCase($input);           // user-profile-settings
```

### Format Detection

[](#format-detection)

```
// Check string formats
var_dump(Inflector::isCamelCase('userAccount'));        // true
var_dump(Inflector::isPascalCase('UserAccount'));       // true
var_dump(Inflector::isSnakeCase('user_account'));       // true
var_dump(Inflector::isScreamingSnakeCase('USER_ACCOUNT')); // true
var_dump(Inflector::isKebabCase('user-account'));       // true
```

### Fluent Interface

[](#fluent-interface)

Chain multiple operations together:

```
use Ykw\Cruet\Inflector;

// Complex transformation chains
$result = Inflector::convert('user_account')
    ->pascalCase()       // UserAccount
    ->snakeCase()        // user_account
    ->screamingSnakeCase() // USER_ACCOUNT
    ->get();

echo $result; // USER_ACCOUNT

// Another example
$result = Inflector::convert('AdminUser')
    ->snakeCase()        // admin_user
    ->kebabCase()        // admin-user
    ->get();

echo $result; // admin-user
```

API Reference
-------------

[](#api-reference)

### Static Case Conversion Methods

[](#static-case-conversion-methods)

- `Inflector::toCamelCase(string $input): string`
- `Inflector::toPascalCase(string $input): string`
- `Inflector::toSnakeCase(string $input): string`
- `Inflector::toScreamingSnakeCase(string $input): string`
- `Inflector::toKebabCase(string $input): string`

### Static Format Detection Methods

[](#static-format-detection-methods)

- `Inflector::isCamelCase(string $input): bool`
- `Inflector::isPascalCase(string $input): bool`
- `Inflector::isSnakeCase(string $input): bool`
- `Inflector::isScreamingSnakeCase(string $input): bool`
- `Inflector::isKebabCase(string $input): bool`

### Fluent Interface

[](#fluent-interface-1)

- `Inflector::convert(string $input): Inflector` - Create fluent chain
- `->camelCase(): Inflector` - Convert to camelCase
- `->pascalCase(): Inflector` - Convert to PascalCase
- `->snakeCase(): Inflector` - Convert to snake\_case
- `->screamingSnakeCase(): Inflector` - Convert to SCREAMING\_SNAKE\_CASE
- `->kebabCase(): Inflector` - Convert to kebab-case
- `->get(): string` - Get final result

Requirements
------------

[](#requirements)

- PHP 8.4 or higher
- No external dependencies

Testing
-------

[](#testing)

Run the test suite:

```
composer test
```

Or run PHPUnit directly:

```
vendor/bin/phpunit
```

Generate test coverage:

```
composer run test-coverage
```

Code Quality
------------

[](#code-quality)

This project uses [Mago](https://mago.carthage.software/) for code formatting, linting, and static analysis:

```
# Format code
mago format

# Run linter
mago lint

# Static analysis
mago analyze

# All quality checks
mago format && mago lint && mago analyze
```

Code quality checks run automatically via GitHub Actions on every push and pull request.

Contributing
------------

[](#contributing)

Contributions are welcome! Please ensure:

1. **Test Coverage**: Add tests for new functionality
2. **Documentation**: Update README for new features
3. **Code Style**: Follow PSR-12 coding standards

License
-------

[](#license)

MIT License - see [LICENSE](LICENSE) file for details.

Credits
-------

[](#credits)

Based on the [Rust cruet library](https://github.com/chrislearn/cruet) by Chris Learn.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance60

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

255d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d088e32143752d8ea6241a0300520d942f9e9877c668f8757a7ec2c317ac903a?d=identicon)[yankewei](/maintainers/yankewei)

---

Top Contributors

[![yankewei](https://avatars.githubusercontent.com/u/19988359?v=4)](https://github.com/yankewei "yankewei (9 commits)")

---

Tags

stringconversionkebab casesentence casesnake casetitle caseTrain casecasecamelcasepascalCasescreaming-snake-case

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ykw-cruet/health.svg)

```
[![Health](https://phpackages.com/badges/ykw-cruet/health.svg)](https://phpackages.com/packages/ykw-cruet)
```

###  Alternatives

[jawira/case-converter

Convert strings between 13 naming conventions: Snake case, Camel case, Pascal case, Kebab case, Ada case, Train case, Cobol case, Macro case, Upper case, Lower case, Sentence case, Title case and Dot notation.

1746.9M79](/packages/jawira-case-converter)[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k394.3M1.5k](/packages/nette-utils)[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k9.2M108](/packages/cuyz-valinor)[spatie/color

A little library to handle color conversions

38118.9M28](/packages/spatie-color)[kirkbushell/eloquence

A set of extensions adding additional functionality and consistency to Laravel's awesome Eloquent library.

573970.0k1](/packages/kirkbushell-eloquence)[opis/string

Multibyte strings as objects

7420.9M7](/packages/opis-string)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
