PHPackages                             lukaswhite/capitalizer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. lukaswhite/capitalizer

ActiveProject[Utility &amp; Helpers](/categories/utility)

lukaswhite/capitalizer
======================

A simple library for capitalizing strings intelligently.

0.0.1(4y ago)187MITPHPPHP &gt;=7.0

Since Sep 18Pushed 4y ago1 watchersCompare

[ Source](https://github.com/lukaswhite/capitalizer)[ Packagist](https://packagist.org/packages/lukaswhite/capitalizer)[ RSS](/packages/lukaswhite-capitalizer/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

Capitalizer
===========

[](#capitalizer)

A package for intelligent string capitalization.

PHP includes the `ucwords` function for capitalizing words in strings, but it's pretty dumb.

Consider the following names:

```
Nigel de Jong
Rajiv van La Parra
Malcolm McDonald

```

...or the following titles:

```
To Be or Not to Be
The Wizard of Oz
Gone With the Wind

```

...or the following places:

```
Newton on the Willow
Stoke on Trent
Stoke D'Abernon

```

This library is designed to properly handle cases like this.

Usage
-----

[](#usage)

Create an instance with no arguments:

```
use Lukaswhite\Capitalizer\Capitalizer;
$capitalizer = new Capitalizer();
```

The method provides four methods for capitalization:

### `title()`

[](#title)

e.g. the title of a book, film, etc.

```
print $capitalizer->title('to be or not to be'); // prints To Be or Not to Be
```

### `name()`

[](#name)

The name of a person

```
print $capitalizer->name('RAJIV VAN LA PARRA'); // prints Rajiv van La Parra
```

### `place()`

[](#place)

The name of a place.

```
print $capitalizer->place('STOKE ON TRENT'); // prints Stoke on Trent
```

### `string()`

[](#string)

A generic string

```
print $capitalizer->title('this is a string); // prints This is a String
```

Customizing Behaviour
---------------------

[](#customizing-behaviour)

You can customise the behaviour of the library using one or more of the following methods:

```
$capitalizer = new Capitalizer();

$capitalizer->addLowercase('con'); // e.g. Chilli con Carne

$capitalizer->addUppercase('php'); // good for acronyms

$capitalizer->addLowercaseName('of'); // only applies to names; e.g. Jesus of Nazareth

$capitalizer->addPrefix('Mc');

$capitalizer->addSuffix('\'s');
```

Note that all of them return the current instance (i.e. a fluent interface), so they can be chained together, for example:

```
$capitalizer = new Capitalizer();

$capitalizer->addLowercase('con')
    ->addUppercase('php')
    ->addLowercaseName('of')
    ->addPrefix('Mc')
    ->addSuffix('\'s');
```

Refer to the source code for more explanation of these methods.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1702d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f1bd633ffdf0f66a73a288c4edcacfa43d214cd95a53384c6fe5ea4b3554dd9d?d=identicon)[lukaswhite](/maintainers/lukaswhite)

---

Top Contributors

[![lukaswhite](https://avatars.githubusercontent.com/u/999014?v=4)](https://github.com/lukaswhite "lukaswhite (2 commits)")

---

Tags

stringscapitalization

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lukaswhite-capitalizer/health.svg)

```
[![Health](https://phpackages.com/badges/lukaswhite-capitalizer/health.svg)](https://phpackages.com/packages/lukaswhite-capitalizer)
```

###  Alternatives

[doctrine/inflector

PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.

11.4k855.8M711](/packages/doctrine-inflector)[snipe/banbuilder

Library to easily handle profanity filtering in PHP projects.

3371.5M3](/packages/snipe-banbuilder)[tamtamchik/namecase

This package allows you to convert names into the correct case where possible.

78506.0k](/packages/tamtamchik-namecase)[delight-im/str

Convenient object-oriented operations on strings

68336.2k2](/packages/delight-im-str)[delight-im/random

The most convenient way to securely generate anything random in PHP

2345.4k](/packages/delight-im-random)[colinodell/indentation

Library to detect and manipulate indentation in strings and files

3911.5k5](/packages/colinodell-indentation)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
