Skip to content

Commit

Permalink
Full name parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Deyter committed Oct 9, 2017
1 parent 048aa33 commit ed78a08
Show file tree
Hide file tree
Showing 14 changed files with 2,163 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Crawling results.
/result

# Code editors.
.idea
#vagrant
.vagrant

# Composer.
vendor/
composer.phar
composer.lock

# Os files.
.DS_Store
Desktop.ini
._*
Thumbs.db
.Spotlight-V100
.Trashes
tmp/
config.json
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

The MIT License (MIT)

Copyright (c) 2017

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
34 changes: 34 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "adci/full-name-parser",
"description": "Parses a human name",
"license": "MIT",
"type": "library",
"keywords": [
"PHP",
"parse",
"parser",
"name",
"full name"
],
"authors": [
{
"name": "ADCI Solutions",
"homepage": "https://www.adcisolutions.com"
}
],
"support": {
"issues": "https://github.com/adci/full-name-parser/issues",
"source": "https://github.com/adci/full-name-parser"
},
"require": {
"php": ">=5.6"
},
"require-dev": {
"phpunit/phpunit": ">=4.8.28 <5"
},
"autoload": {
"psr-4": {
"ADCI\\FullNameParser\\": "src/"
}
}
}
21 changes: 21 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<phpunit
colors="true"
bootstrap="tests/bootstrap.php">
<testsuites>
<testsuite name="Full Name Parser tests">
<directory>tests</directory>
</testsuite>
</testsuites>
<!-- Filter for coverage reports. -->
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
<!-- By definition test classes have no tests. -->
<exclude>
<directory suffix="Test.php">./src</directory>
<directory suffix="TestBase.php">./src</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
33 changes: 33 additions & 0 deletions src/Exception/FirstNameNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/**
* @file
* Class of FirstNameNotFoundException.
*/

namespace ADCI\FullNameParser\Exception;

/**
* Exception of first name not found.
*
* Class FirstNameNotFoundException.
*
* @package FullNameParser
*/
class FirstNameNotFoundException extends NameParsingException
{
/**
* Default message text.
*
* @var string
*/
const MESSAGE = "Couldn't find a first name.";

/**
* {@inheritdoc}
*/
public function __construct($message = null, $code = 0, \Throwable $previous = null)
{
parent::__construct($message ? $message : self::MESSAGE, $code, $previous);
}
}
34 changes: 34 additions & 0 deletions src/Exception/IncorrectInputException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/**
* @file
* Class of IncorrectInputException.
*/

namespace ADCI\FullNameParser\Exception;

/**
* Exception of incorrect input.
*
* Class IncorrectInputException.
*
* @package FullNameParser
*/
class IncorrectInputException extends NameParsingException
{

/**
* Default message text.
*
* @var string
*/
const MESSAGE = "Incorrect input to parse.";

/**
* {@inheritdoc}
*/
public function __construct($message = null, $code = 0, \Throwable $previous = null)
{
parent::__construct($message ? $message : self::MESSAGE, $code, $previous);
}
}
34 changes: 34 additions & 0 deletions src/Exception/LastNameNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/**
* @file
* Class of LastNameNotFoundException.
*/

namespace ADCI\FullNameParser\Exception;

/**
* Exception last name not found.
*
* Class LastNameNotFoundException.
*
* @package FullNameParser
*/
class LastNameNotFoundException extends NameParsingException
{

/**
* Default message text.
*
* @var string
*/
const MESSAGE = "Couldn't find a last name.";

/**
* {@inheritdoc}
*/
public function __construct($message = null, $code = 0, \Throwable $previous = null)
{
parent::__construct($message ? $message : self::MESSAGE, $code, $previous);
}
}
20 changes: 20 additions & 0 deletions src/Exception/ManyMiddleNamesException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/**
* @file
* Class of ManyMiddleNamesException.
*/

namespace ADCI\FullNameParser\Exception;

/**
* Exception of many middle names found.
*
* Class ManyMiddleNamesException.
*
* @package FullNameParser
*/
class ManyMiddleNamesException extends NameParsingException
{

}
33 changes: 33 additions & 0 deletions src/Exception/NameParsingException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/**
* @file
* Class of NameParsingException.
*/

namespace ADCI\FullNameParser\Exception;

/**
* Any exception for name parsing.
*
* Class NameParsingException.
*
* @package FullNameParser
*/
class NameParsingException extends \Exception
{
/**
* NameParsingException constructor.
*
* @param string $message
* Message of error.
* @param int $code
* Code of error.
* @param \Throwable|null $previous
* Previously chained error.
*/
public function __construct($message, $code = 0, \Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
}
}

0 comments on commit ed78a08

Please sign in to comment.