An English pluralization and singularization engine for HolyPHP with built-in irregular words, uncountable nouns, case preservation, custom rule registration, count formatting, and ordinal numbers.
All top-level functions operate on a shared default PluralEngine instance.
plural_pluralize(string $word): string
Returns the English plural form of $word, preserving lowercase, Title Case, and UPPERCASE formatting. Uncountable nouns and already-plural irregulars are returned unchanged.
plural_singularize(string $word): string
Returns the English singular form of $word, preserving original casing. Uncountable nouns and already-singular irregulars are returned unchanged.
plural_is_plural(string $word): bool
Returns true if $word is in plural form (or is uncountable), false otherwise.
plural_is_singular(string $word): bool
Returns true if $word is in singular form (or is uncountable), false otherwise.
All functions validate their inputs and throw an Exception prefixed with plural: on invalid input:
Empty or whitespace-only $word in plural_pluralize, plural_singularize, plural_is_plural, plural_is_singular, or plural_count: plural: word must be non-empty
Empty singular or plural argument in plural_add_irregular: plural: singular and plural words must be non-empty
Empty word in plural_add_uncountable: plural: uncountable word must be non-empty
Empty suffix in plural_add_plural_rule or plural_add_singular_rule: plural: rule suffix must be non-empty
Examples
01Quick start
Bundled with the compiler — import "plural"; works offline in any file, or add it to a project with hphp install plural.