-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now it's possible to use the class without any special character The public static method was removed
- Loading branch information
1 parent
aa8917e
commit 0031cfb
Showing
3 changed files
with
93 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,61 @@ | ||
# nameize | ||
|
||
A simple class to correctly capitalize full names, specially Brazilian names. | ||
[![Build Status](https://travis-ci.com/enricodias/nameize.svg?branch=master)](https://travis-ci.com/enricodias/nameize) | ||
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/ce9cfa2739534021a15aebfb7037ef1d)](https://www.codacy.com/manual/enricodias/nameize?utm_source=github.com&utm_medium=referral&utm_content=enricodias/nameize&utm_campaign=Badge_Coverage) | ||
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/ce9cfa2739534021a15aebfb7037ef1d)](https://www.codacy.com/manual/enricodias/nameize?utm_source=github.com&utm_medium=referral&utm_content=enricodias/nameize&utm_campaign=Badge_Grade) | ||
|
||
A simple class to correctly capitalize full names. | ||
|
||
## Installation | ||
|
||
Require this package with Composer in the root directory of your project. | ||
Require this package with Composer in the root directory of your project | ||
|
||
```bash | ||
composer require enricodias/nameize | ||
``` | ||
|
||
and include the composer's autoloader in your code | ||
|
||
```php | ||
include 'vendor/autoload.php'; | ||
``` | ||
|
||
|
||
## Usage | ||
|
||
### Creating an object instance | ||
### Simple usage | ||
|
||
```php | ||
$Object = new \enricodias\nameize(); | ||
$Object->nameize("joão da silva"); // returns João da Silva | ||
echo (new \enricodias\nameize())->name("Carlo D'ippoliti"); // Carlo D'Ippoliti | ||
``` | ||
|
||
### Using a static method | ||
or | ||
|
||
```php | ||
\enricodias\nameize::format("mArIa dAs DORES"); // returns Maria das Dores | ||
$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 second parameter is optional and receives a single (or list of) special characters. Those characters sinalizes that the next letter should be in upper case. If no character is specified, the default ```array("'", '-')``` is used. | ||
The constructor has an optional argument that receives an array of special characters. Those characters sinalizes 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. | ||
|
||
```php | ||
use enricodias\nameize; | ||
|
||
echo (new nameize("'"))->name("john o'grady-smith"); // John O'Grady-smith | ||
echo (new nameize(array('-')))->name("john o'grady-smith"); // John O'grady-Smith | ||
``` | ||
|
||
or | ||
|
||
```php | ||
\enricodias\nameize::format("john o'grady-smith"); // returns John O'Grady-Smith | ||
\enricodias\nameize::format("john o'grady-smith", "'"); // returns John O'Grady-smith | ||
$nameize = new \enricodias\nameize("'"); | ||
echo $nameize->name("Matteo Dell'aqcua"); // Matteo Dell'Aqcua | ||
echo $nameize->name("john o'grady-smith"); // John O'Grady-smith | ||
``` | ||
|
||
## Other features | ||
## Additional features | ||
|
||
If you need more features, I recommend using a name parser such as https://github.com/theiconic/name-parser | ||
If you need more features I recommend using a name parser such as <https://github.com/theiconic/name-parser> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters