lhcze/fqcn-stripper
最新稳定版本:1.0.0
Composer 安装命令:
composer require lhcze/fqcn-stripper
包简介
Utility for extracting and formatting FQCN base names with string transformation support.
README 文档
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
统计信息
- 总下载量: 873
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-05-26