2017 © Pedro Peláez
 

library estimated-reading-time

Calculate the reading time for any given webpage

image

aheenam/estimated-reading-time

Calculate the reading time for any given webpage

  • Monday, February 19, 2018
  • by rathesDot
  • Repository
  • 2 Watchers
  • 9 Stars
  • 20 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 54 % Grown

The README.md

Estimated Reading Time

Calculate the estimated reading time of any given webpage., (*1)

Installation

You can install the package via composer:, (*2)

composer require aheenam/estimated-reading-time

Usage

The following command returns the rounded number of estimated minutes to read the given text., (*3)

<?php

// text with 400 words
$text = \Faker\Factory::create()->words(400, true);

// returns 2
(new EstimatedReadingTime)
    ->setText($text)
    ->calculateTime();

In most of the cases in the web, you do not have a plain text but a HTML fragment, but that does not matter. Internally the tags are stripped away when you use setText(), (*4)

Set default words per minute

By default the assumption is made that one is able to read 200 words per minute, but you can easily change this config by setting the property $wordsPerMinute, (*5)

<?php

// text with 400 words
$text = \Faker\Factory::create()->words(400, true);

// returns 1
(new EstimatedReadingTime)
    ->setWordsPerMinute(400)
    ->setText($text)
    ->calculateTime();

Get exact time

Another default configuration is that this package returns a rounded number of minutes. You can though get a exact value as well., (*6)

<?php

$text = \Faker\Factory::create()->words(650, true);

// returns 3.25
(new EstimatedReadingTime)
    ->exactTime(true)
    ->setText($text)
    ->calculateTime();

// returns 3
(new EstimatedReadingTime)
    ->setText($text)
    ->calculateTime();

Changelog

Check CHANGELOG for the changelog, (*7)

Testing

To run tests use, (*8)

$ composer test

Contributing

Security

If you discover any security related issues, please email your@mail.tld or use the issue tracker of GitHub., (*9)

About

Aheenam is a small company from NRW, Germany creating custom digital solutions. Visit our website to find out more about us., (*10)

License

The MIT License (MIT). Please see License File for more information., (*11)

The Versions

19/02 2018

dev-master

9999999-dev

Calculate the reading time for any given webpage

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

14/02 2018

0.1.0

0.1.0.0

Calculate the reading time for any given webpage

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires