Webifi / name-parser

A universal, language-independent name parser PHP library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

THE ICONIC Name Parser

Build Status Coverage Status Scrutinizer Code Quality Latest Stable Version Total Downloads License Dependency Status

Purpose

This is a universal, language-independent name parser.

Its purpose is to split a single string containing a full name, possibly including salutation, initials, suffixes etc., into meaningful parts like firstname, lastname, initials, and so on.

It is mostly tailored towards english names but works pretty well with non-english names as long as they use latin spelling.

E.g. Mr Anthony R Von Fange III is parsed to

  • salutation: Mr.
  • firstname: Anthony
  • initials: R
  • lastname: von Fange
  • suffix: III

Setup

composer require theiconic/name-parser

Usage

<?php

$parser = new TheIconic\NameParser\Parser();

$name = $parser->parse($input);

echo $name->getSalutation();
echo $name->getFirstname();
echo $name->getLastname();
echo $name->getMiddlename();
echo $name->getNickname();
echo $name->getInitials();
echo $name->getSuffix();

An empty string is returned for missing parts.

Examples

An wide array of successfully parsed names can be found in the parser unit test.

License

THE ICONIC Name Parser library for PHP is released under the MIT License.

About

A universal, language-independent name parser PHP library

License:MIT License


Languages

Language:PHP 100.0%