lhcze / fqcn-stripper
Utility for extracting and formatting FQCN base names with string transformation support.
Installs: 477
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/lhcze/fqcn-stripper
Requires
- php: >=8.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.44
- phpstan/phpstan: ^1.11
- phpunit/phpunit: ^10.5
- slevomat/coding-standard: ^8.18
- squizlabs/php_codesniffer: ^3.7
This package is auto-updated.
Last update: 2025-12-26 10:33:45 UTC
README
FQCN Stripper is a small and flexible PHP 8.3+ utility for extracting and formatting the base class name from a Fully-Qualified Class Name (FQCN).
It supports string transformations like lowercase, UPPERCASE, and Ucfirst β with optional multibyte-safe handling (via mbstring).
π Features
- Extracts base class name from a fully-qualified name
- Bitmask modifiers for string formatting:
LOWERβ lowercasedUCβ ucfirstUPPERβ fully uppercasedLOW_UCβ lower + ucfirstMULTIBYTEβ applies transformations usingmb_functions
- Supports both strings and objects
- Caches internally for performance
- Simple API for batch processing
π οΈ Requirements
- PHP 8.3+
- Optional:
mbstringextension (forMULTIBYTE)
π¦ Installation
composer require lhcze/fqcn-stripper
β Usage
use Lhcze\FqcnStripper\FqcnStripper; FqcnStripper::strip('App\\Entity\\User'); // "User" FqcnStripper::strip('App\\Entity\\User', FqcnStripper::LOWER); // "user" FqcnStripper::strip('App\\Entity\\User', FqcnStripper::LOW_UC); // "User" FqcnStripper::strip('App\\Entity\\User', FqcnStripper::UPPER); // "USER"
FqcnStripper::strip('App\\Entity\\Γser', FqcnStripper::LOW_UC | FqcnStripper::MULTIBYTE); // "Γser"
$object = new \App\Entity\User(); FqcnStripper::strip($object, FqcnStripper::LOWER); // "user"
FqcnStripper::strip('App\\WeirdObjects\\UserHandlerDtoEvent', FqcnStripper::TRIM_POSTFIX) // User
π Batch usage
$list = [ 'App\\Model\\CustomerModel', 'App\\Entity\\OrderEntity', 'App\\Controller\\Admin\\DashboardController', ]; FqcnStripper::stripThemAll($list, FqcnStripper::LOW_UC | FqcnStripper::TRIM_POSTFIX); // ["Customer", "Order", "Dashboard"]
π§ͺ Code Quality & Local Development
Tools & Standards
| Command | Standards | Description |
|---|---|---|
composer phpunit |
N/A | Run PHPUnit tests |
composer cs |
PSR12 | Check code style (dry-run) |
composer cs-fix |
PSR12 | Auto-fix coding standards |
composer phpstan |
Level 9 | Run static analysis (PHPStan) |
composer check |
N/A | Runs all checks at once |
Install dependencies and run QA tools:
composer install composer check