承接 ferryhopper/php-string-formatter 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ferryhopper/php-string-formatter

最新稳定版本:v0.1.0

Composer 安装命令:

composer require ferryhopper/php-string-formatter

包简介

A simple and configurable string formatting pipeline for PHP.

README 文档

README

A simple and configurable string formatting pipeline for PHP.

Define formatting rules using a compact, readable DSL like:

padLeft:10:0;replace:_:space;padAfterFirst:11:0

This library lets you manipulate strings in a declarative and reusable way — ideal for formatting ticket numbers, codes, IDs, or any value that needs structured transformation.

🚀 Installation

composer require ferryhopper/php-string-formatter

🧪 Usage

use StringFormatter\StringFormatter;

$formatted = StringFormatter::apply('K563793', 'remove:space;replace:K:A;padAfterFirst:11:0');
// Returns: "K 00000563793"

🛠 Supported Formatters

Formatter Description
padLeft:length:char Left-pads the string to length using char.
padRight:length:char Right-pads the string to length using char.
replace:search:replace Replaces all occurrences of search with replace.
remove:target Removes all occurrences of target.
padAfterFirst:length:char Pads the part after the first character to length using char.

🔤 Special Keywords

  • Use "space" instead of a literal space character.
    • replace:_:space → replaces _ with a space
    • remove:space → removes all spaces

🧪 Testing

vendor/bin/phpunit

📦 Roadmap Ideas

  • Custom formatter registration
  • Support for named pipelines
  • Optional error handling modes (fail-fast vs silent)

👨‍💻 Authors

Maintained by the Ferryhopper engineering team.
Initial development by @vlahanas.

📝 License

MIT — see LICENSE for details.

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-07