enricodias/nameize 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

enricodias/nameize

Composer 安装命令:

composer require enricodias/nameize

包简介

A simple class to correctly capitalize full names.

README 文档

README

Build Status Codacy Badge Codacy Badge Latest version Downloads total License

A simple class to correctly capitalize full names.

Installation

Require this package with Composer in the root directory of your project

composer require enricodias/nameize

and include the composer's autoloader in your code

include 'vendor/autoload.php';

Usage

Simple usage

echo \enricodias\Nameize::create()->name("Carlo D'ippoliti"); // Carlo D'Ippoliti

or

$nameize = new \enricodias\Nameize();

echo $nameize->name("Matteo Dell'aqcua");  // Matteo Dell'Aqcua
echo $nameize->name("john o'grady-smith"); // John O'Grady-Smith

Specifying special characters

The method setAllowedCharacters() receives an array of special characters. Those characters signalizes that the next letter should be in upper case. If no character is specified, the default array("'", '-') is used. If you pass a string, it will be consider a single character.

$nameize = new \enricodias\Nameize();

$nameize->setAllowedCharacters("'");

echo $nameize->name("Matteo Dell'aqcua");  // Matteo Dell'Aqcua
echo $nameize->name("john o'grady-smith"); // John O'Grady-smith

or with method chaining:

echo \enricodias\Nameize::create()
    ->setAllowedCharacters("-")
    ->name("john o'grady-smith"); // John O'grady-Smith

Minimum length

Some languages require capitalization on the first letter of every word regardless of their size. The setMinLength() method sets the minimum length of which words will be capitalized (min: 1, max: 5, default: 4).

$nameize = new \enricodias\Nameize();

$nameize->setMinLength(1);

echo $nameize->name("Tri vu phu");    // Tri Vu Phu
echo $nameize->name("Shuanping dai"); // Shuanping Dai

or with method chaining:

echo \enricodias\Nameize::create()
    ->setMinLength(1)
    ->name("Tri vu phu"); // Tri Vu Phu

Your application may detect the user's country and use the appropriate minLength value.

Additional features

If you need more features I recommend using a name parser such as https://github.com/theiconic/name-parser

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-06-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固