Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cmgmyr/title-formatter
A simple to use text formatter, primarily used for page/blog titles
https://github.com/cmgmyr/title-formatter
composer composer-package hacktoberfest package php
Last synced: 13 days ago
JSON representation
A simple to use text formatter, primarily used for page/blog titles
- Host: GitHub
- URL: https://github.com/cmgmyr/title-formatter
- Owner: cmgmyr
- License: mit
- Created: 2019-01-24T21:21:25.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-10-03T04:43:36.000Z (about 1 year ago)
- Last Synced: 2024-10-11T01:09:34.542Z (27 days ago)
- Topics: composer, composer-package, hacktoberfest, package, php
- Language: PHP
- Homepage:
- Size: 41 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
[![Tests](https://github.com/cmgmyr/title-formatter/actions/workflows/run-tests.yml/badge.svg)](https://github.com/cmgmyr/title-formatter/actions/workflows/run-tests.yml)
[![Latest Version](https://img.shields.io/github/release/cmgmyr/title-formatter.svg)](https://github.com/cmgmyr/title-formatter/releases)
[![Total Downloads](https://img.shields.io/packagist/dt/cmgmyr/title-formatter.svg)](https://packagist.org/packages/cmgmyr/title-formatter)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)# Title Text Formatter
A simple to use text formatter, primarily used for page/blog titles.
## Install
Via Composer
```
"require": {
"cmgmyr/title-formatter": "~3.0"
}
```## Usage
```php
use Cmgmyr\TitleFormatter\TitleFormatter;$title = "this is a messy title. [can you fix it?]";
$title = TitleFormatter::titleCase($title);
echo $title; // This is a Messy Title. [Can You Fix It?]
```## Formatting "Rules"
1. First word in a sentence is capitalized
2. Last word in a sentence is capitalized
3. Words within brackets (or similar) are capitalized, similar to rules #1 & #2
4. Words within the `$ignoredWords` array should not be capitalized as long as it doesn't conflict with rules #1-#3
5. Words preceded by multiple special characters should be capitalized: $$$Money
6. All dashed words should be capitalized: Super-Awesome-Post
7. 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](.github/CONTRIBUTING.md) for details.
## Security Vulnerabilities
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
## Credits
- [Chris Gmyr](https://github.com/cmgmyr)
- [All Contributors](../../contributors)