spartz / text-formatter
A simple to use text formatter, primarily used for page/blog titles
Installs: 5 828
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 8
Forks: 1
Open Issues: 0
Requires
- php: >=5.4.0
- ext-mbstring: *
Requires (Dev)
- phpunit/phpunit: 4.*
- scrutinizer/ocular: ~1.1
This package is not auto-updated.
Last update: 2022-02-01 12:46:55 UTC
README
Title Text Formatter
A simple to use text formatter, primarily used for page/blog titles.
Install
Via Composer
"require": {
"spartz/text-formatter": "~1.0"
}
Usage
use Spartz\TextFormatter\TextFormatter;
$title = "this is a messy title. [can you fix it?]";
$title = TextFormatter::titleCase($title);
echo $title; // This is a Messy Title. [Can You Fix It?]
Formatting "Rules"
- First word in a sentence is capitalized
- Last word in a sentence is capitalized
- Words within brackets (or similar) are capitalized, similar to rules #1 & #2
- Words within the
$ignoredWords
array should not be capitalized as long as it doesn't conflict with rules #1-#3 - Words preceded by multiple special characters should be capitalized: $$$Money
- All dashed words should be capitalized: Super-Awesome-Post
- Ignore words that already include at least one uppercase letter. We'll assume that the author knows what they're doing: eBay, iPad, McCormick, etc
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email Chris Gmyr instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.