PHPackages                             davechild/textstatistics - 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. davechild/textstatistics

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

davechild/textstatistics
========================

PHP package to measure the readability of text according to various algorithms.

1.0.3(7y ago)4622.0M—6.9%109[4 PRs](https://github.com/DaveChild/Text-Statistics/pulls)19BSD-2-ClausePHPPHP &gt;=7.2.0CI passing

Since Sep 4Pushed 3mo ago25 watchersCompare

[ Source](https://github.com/DaveChild/Text-Statistics)[ Packagist](https://packagist.org/packages/davechild/textstatistics)[ Docs](https://github.com/DaveChild/Text-Statistics)[ RSS](/packages/davechild-textstatistics/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (6)Used By (19)

PHP Text Statistics
===================

[](#php-text-statistics)

[![Build Status](https://camo.githubusercontent.com/cf79b179932fd05506264d42cac3829458d8a940d02a8690d4fd059f26941f8d/68747470733a2f2f7472617669732d63692e6f72672f446176654368696c642f546578742d537461746973746963732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/DaveChild/Text-Statistics) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/46779f54ca81c232a21bf785c2bbcb3ae4207c9a9e012f54edd16a3d27ab9a19/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f446176654368696c642f546578742d537461746973746963732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/DaveChild/Text-Statistics/?branch=master) [![Code Coverage](https://camo.githubusercontent.com/a789ecc83815cd7ef87ba27ad0dba5cf6cdceb110f6c4b6d83a49d5afd25bb58/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f446176654368696c642f546578742d537461746973746963732f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/DaveChild/Text-Statistics/?branch=master)

The PHP Text Statistics class will help you to indentify issues with your website content, especially with readability.

It allows you to measure the readability of text using common scoring systems, including:

- Flesch Kincaid Reading Ease
- Flesch Kincaid Grade Level
- Gunning Fog Score
- Coleman Liau Index
- SMOG Index
- Automated Reability Index
- Dale-Chall Readability Score
- Spache Readability Score

One of the biggest challenges with measuring text readability is the counting of syllables, which can be tricky to work out. There are rules in the Statistics class for working out the syllable count of words, and a large list of words to test these rules against.

Please feel free to add to the test word list, especially if you can find words whose syllable count is not correctly calculated (even more especially if you can also add code to the class so your word is correctly handled!).

Homographs are going to be impossible to calculate as they depend on context (i.e., "he moped around the house", "she rode her moped to school), but there are few enough of these not to be a concern. There is a by-no-means-comprehensive list of these in the resources folder.

Installation
------------

[](#installation)

### Using Composer

[](#using-composer)

```
    {
        "require": {
            "davechild/textstatistics": "1.*"
        }
    }
```

> If using a version of PHP &lt; 7.2, specify version 1.0.2.

### Measuring Readability

[](#measuring-readability)

```
use DaveChild\TextStatistics as TS;
$textStatistics = new TS\TextStatistics;
$text = 'The quick brown fox jumped over the lazy dog.';
echo 'Flesch-Kincaid Reading Ease: ' . $textStatistics->fleschKincaidReadingEase($text);
```

### More Text Shenanigans!

[](#more-text-shenanigans)

Included with this package are several classes with static methods which can be called independently. If required, you can pass a text encoding to these methods as a second parameter.

#### Pluralise and Singularise Words

[](#pluralise-and-singularise-words)

```
echo DaveChild\TextStatistics\Pluralise::getPlural('banana'); // bananas
echo DaveChild\TextStatistics\Pluralise::getSingular('bananas'); // banana
```

#### Count Syllables

[](#count-syllables)

```
echo DaveChild\TextStatistics\Syllables::syllableCount('banana'); // 3
```

#### Letter, Sentence, Word Counts

[](#letter-sentence-word-counts)

```
echo DaveChild\TextStatistics\Text::textLength('I ate a banana.'); // 15
echo DaveChild\TextStatistics\Text::letterCount('I ate a banana.'); // 11
echo DaveChild\TextStatistics\Text::wordCount('I ate a banana.'); // 4
echo DaveChild\TextStatistics\Text::sentenceCount('I ate a banana.'); // 1
```

Useful Links
------------

[](#useful-links)

**Homepage and Live Version**

**JavaScript Port**

**License**

###  Health Score

56

—

FairBetter than 98% of packages

Maintenance53

Moderate activity, may be stable

Popularity62

Solid adoption and visibility

Community38

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 73.6% 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

Every ~482 days

Total

4

Last Release

2828d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.3.0

1.0.3PHP &gt;=7.2.0

### Community

Maintainers

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

---

Top Contributors

[![DaveChild](https://avatars.githubusercontent.com/u/53308?v=4)](https://github.com/DaveChild "DaveChild (64 commits)")[![jrfnl](https://avatars.githubusercontent.com/u/663378?v=4)](https://github.com/jrfnl "jrfnl (12 commits)")[![DominicVonk](https://avatars.githubusercontent.com/u/3958086?v=4)](https://github.com/DominicVonk "DominicVonk (3 commits)")[![garymarkfuller](https://avatars.githubusercontent.com/u/6162988?v=4)](https://github.com/garymarkfuller "garymarkfuller (1 commits)")[![migurski](https://avatars.githubusercontent.com/u/58730?v=4)](https://github.com/migurski "migurski (1 commits)")[![mryand](https://avatars.githubusercontent.com/u/256007?v=4)](https://github.com/mryand "mryand (1 commits)")[![repat](https://avatars.githubusercontent.com/u/516807?v=4)](https://github.com/repat "repat (1 commits)")[![Aaron3](https://avatars.githubusercontent.com/u/2073168?v=4)](https://github.com/Aaron3 "Aaron3 (1 commits)")[![richtom80](https://avatars.githubusercontent.com/u/2042921?v=4)](https://github.com/richtom80 "richtom80 (1 commits)")[![bryant1410](https://avatars.githubusercontent.com/u/3905501?v=4)](https://github.com/bryant1410 "bryant1410 (1 commits)")[![DrDub](https://avatars.githubusercontent.com/u/315403?v=4)](https://github.com/DrDub "DrDub (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/davechild-textstatistics/health.svg)

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

###  Alternatives

[florianv/swap

Exchange rates library for PHP

1.3k6.4M16](/packages/florianv-swap)[akaunting/laravel-money

Currency formatting and conversion package for Laravel

7825.3M18](/packages/akaunting-laravel-money)[kartik-v/yii2-widget-affix

A scrollspy and affixed enhanced navigation to highlight page sections (sub repo split from yii2-widgets)

153.8M3](/packages/kartik-v-yii2-widget-affix)

PHPackages © 2026

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