承接 alistairshaw/name-exploder 相关项目开发

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

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

alistairshaw/name-exploder

Composer 安装命令:

composer require alistairshaw/name-exploder

包简介

Simple class to provide title, first name, middle initial and last name from a full name field (or in reverse). Works well for western(ish) names, but has sensible defaults otherwise

README 文档

README

Via Composer

$ composer require alistairshaw/name-exploder:^0.1

Titles

There is some data included for titles in English (default) and Spanish. If you need it for another language, please feel free to pull request or simply send me the list and I will add your language. Include any rules so we can improve the plugin.

It is possible to attach your own data (see below).

Usage

require 'vendor/autoload.php';

use AlistairShaw\NameExploder\NameExploder;

// You can get a Name object by passing in the full name
$nameExploder = new NameExploder();
$name = $nameExploder->explode('Mr Alistair Shaw');

// get the pieces back
echo $name->firstName();
echo $name->lastName();
echo $name->title();
echo $name->middleInitial();

// cast the Name object as string to just get full name back
echo $name;

// pass in the language for the titles (default is english)
$nameExploder = new NameExploder('es');
$name = $nameExploder->explode('Mr Alistair Shaw');

// make a name from pieces
$name = $nameExploder->implode('Alistair', 'Shaw', '', 'Mr');

// update the title on a name
$name = $nameExploder->updateTitle('Dr', $name);

Attaching your own data for titles

You can easily write a new repository (implement \AlistairShaw\NameExploder\Title\TitleRepository) and inject it into the main class Just ensure you return an array of Title objects, and it will work great!

require 'vendor/autoload.php';

use AlistairShaw\NameExploder\NameExploder;

// pass in a custom repository implementation
$nameExploder = new NameExploder('es', new CustomTitleRepository());
$name = $nameExploder->explode('Mr Alistair Shaw');

Notes

I realise that this is pretty basic at the moment, I plan to improve it over time, specifically adding new languages is high on the list of priorities. Would love to hear from people who speak non-latin languages to make this work for them.

Contributing

Contributions are very welcome and will be fully credited, just please make sure to add tests.

Credits

License

The MIT License (MIT).

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-04-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固