承接 omar-haris/card-name-fit 相关项目开发

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

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

omar-haris/card-name-fit

Composer 安装命令:

composer require omar-haris/card-name-fit

包简介

PHP library to squeeze Arabic or English personal names to a fixed length for ID, bank or payment cards.

README 文档

README

A simple PHP library that solves the headache of fitting names on cards and badges. If you've ever struggled with names that are too long for credit cards, ID badges, or passport printing, this is your solution.

Latest Version on Packagist Tests PHP Version License: MIT Total Downloads

Why This Library?

We've all seen ID cards with awkwardly truncated names or ridiculously small fonts trying to fit long names. This library fixes that problem with intelligent name formatting for fixed-width spaces.

It's especially useful for:

  • Card printing (credit, debit, ID, membership)
  • Name badges and tags
  • Passports and government IDs
  • Any system with character limits for names

Key Features

  • Smart formatting that preserves readability
  • Handles both English and Arabic names with different strategies
  • Adjustable character limits to match your exact requirements
  • UTF-8 support for international names
  • No external dependencies besides PHP's mbstring

Installation

Just run:

composer require omar-haris/card-name-fit

Basic Usage

use CardNameFit\NameFormatter;

// Create a formatter with 20-character limit
$formatter = new NameFormatter(20);

// Format some names
echo $formatter->format('John William Smith');             // "John William Smith"
echo $formatter->format('John William Alexander Smith');   // "John William Smith"

// Works with Arabic names too
echo $formatter->format('محمد عبد الرحمن العبد الله');     // "محمد عبد الرحمن"

Formatting Strategies

For English Names

The library offers two approaches:

1. GREEDY (default)

Keeps full middle names when possible, drops them when needed. People generally prefer seeing their complete names rather than initials.

// With 20 character limit
$formatter = new NameFormatter(20, NameFormatter::ENGLISH_GREEDY);

echo $formatter->format('John Smith');                   // "John Smith"
echo $formatter->format('John William Smith');           // "John William Smith"
echo $formatter->format('John William Alexander Smith'); // "John William Smith" 
                                                         // (drops "Alexander")

2. DENSE

Ensures every name part appears, at least as an initial. Better when all name components must be represented.

// With 20 character limit
$formatter = new NameFormatter(20, NameFormatter::ENGLISH_DENSE);

echo $formatter->format('John William Alexander Smith'); // "John W. A. Smith"
                                                         // (includes all parts)

For Arabic Names

Arabic names use a simple left-to-right approach, preserving whole words since initials don't make sense in Arabic.

$formatter = new NameFormatter(25);

echo $formatter->format('محمد عبد الرحمن العبد الله'); // "محمد عبد الرحمن"

Edge Cases Handled

Very Long Names

The library handles unusually long names gracefully:

$formatter = new NameFormatter(20);

// Long last name
echo $formatter->format('John Wolfeschlegelsteinhausenbergerdorff');
// "John Wolfeschlegelst"

Whitespace Cleanup

No need to worry about extra spaces or inconsistent formatting:

$formatter = new NameFormatter(20);
echo $formatter->format('  John   William   Smith  '); // "John William Smith"

Configuration

/**
 * @param int    $maxLength   Maximum allowed characters (≥ 1)
 * @param string $englishMode Strategy: ENGLISH_GREEDY or ENGLISH_DENSE
 * @param string $encoding    Character encoding (default: UTF-8)
 */
public function __construct(
    int    $maxLength   = 35,
    string $englishMode = self::ENGLISH_GREEDY,
    string $encoding    = 'UTF-8'
)

Security & Compliance

This library only formats text - it doesn't store or transmit any personal data. It's designed with:

  • GDPR considerations (no data retention)
  • PCI DSS compatibility (no cardholder data storage)

Requirements

  • PHP 8.3+
  • mbstring extension

License

MIT License. See the LICENSE file.

Credits

omar-haris/card-name-fit 适用场景与选型建议

omar-haris/card-name-fit 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 155 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 04 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「visa」 「id-card」 「credit-card」 「debit-card」 「php-library」 「identity-card」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 omar-haris/card-name-fit 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 omar-haris/card-name-fit 我们能提供哪些服务?
定制开发 / 二次开发

基于 omar-haris/card-name-fit 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-28