PHPackages                             midesweb/reading-time - 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. midesweb/reading-time

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

midesweb/reading-time
=====================

Reading time PHP class calculator

v0.3.2(10mo ago)02MITPHPPHP &gt;=8.1CI passing

Since Jun 11Pushed 10mo agoCompare

[ Source](https://github.com/midesweb/reading-time)[ Packagist](https://packagist.org/packages/midesweb/reading-time)[ RSS](/packages/midesweb-reading-time/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (2)Versions (10)Used By (0)

Reading Time PHP Calculator
===========================

[](#reading-time-php-calculator)

`EstimatedReadingTime` is a lightweight PHP utility that calculates the estimated reading time (in minutes) for a given block of HTML or plain text content.

It uses a simple heuristic: an average reading speed of **120 words per minute**. It strips HTML tags from the content before counting the words and rounds the result to the nearest full minute (rounding up if the leftover seconds exceed 30 seconds).

✅ Features
----------

[](#-features)

- Automatically strips HTML tags before processing
- Calculates reading time based on word count
- Easy to update the content dynamically
- Supports human-readable output in English (`EN`) and Spanish (`ES`)

---

🔖 Installation
--------------

[](#-installation)

```
composer require midesweb/reading-time
```

🧱 Basic Example
---------------

[](#-basic-example)

```
use Midesweb\ReadingTime\EstimatedReadingTime;

$content = "This is a sample article with some HTML content.";
$estimator = new EstimatedReadingTime($content);

$minutes = $estimator->getEstimatedReadingMinutes();

echo "Estimated reading time: {$minutes} minute(s)";
```

### 🔁 Updating the content

[](#-updating-the-content)

```
$estimator->updateContent("New content goes here...");
$minutes = $estimator->getEstimatedReadingMinutes();
```

---

🌍 Localized Read Time Output
----------------------------

[](#-localized-read-time-output)

You can get a localized string describing the estimated read time using `getReadTime()`.
The default language is English (`EN`), but you can switch to Spanish (`ES`) using `setLanguage()`:

```
$estimator = new EstimatedReadingTime($content);

// English (default)
echo $estimator->getReadTime();
// Output: "1 minute", "3 minutes", "1 hour and 5 minutes", etc.

// Spanish
echo $estimator->setLanguage('es')->getReadTime();
// Output: "1 minuto", "3 minutos", "1 hora y 5 minutos", etc.
```

> 🔒 Only `EN` and `ES` are supported. Invalid languages will throw an `InvalidArgumentException`.

---

🧪 How it works
--------------

[](#-how-it-works)

1. Strips HTML tags from the input.
2. Counts words using `str_word_count()`.
3. Divides by 120 (average words per minute).
4. Rounds up the result if more than 30 seconds remain.
5. Optionally returns a localized human-readable string.

---

💡 Requirements
--------------

[](#-requirements)

- PHP **7.4 or higher**

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance54

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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

Every ~4 days

Total

8

Last Release

308d ago

PHP version history (2 changes)0.0.1PHP &gt;=7.4

v0.1.0PHP &gt;=8.1

### Community

Maintainers

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

---

Top Contributors

[![midesweb](https://avatars.githubusercontent.com/u/281585?v=4)](https://github.com/midesweb "midesweb (21 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/midesweb-reading-time/health.svg)

```
[![Health](https://phpackages.com/badges/midesweb-reading-time/health.svg)](https://phpackages.com/packages/midesweb-reading-time)
```

###  Alternatives

[jansenfelipe/cidades-gratis

Com esse pacote você poderá consultar, gratuitamente, Cidades diretamente no site do IBGE.

423.5k](/packages/jansenfelipe-cidades-gratis)

PHPackages © 2026

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