aheenam/estimated-reading-time 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aheenam/estimated-reading-time

最新稳定版本:0.1.0

Composer 安装命令:

composer require aheenam/estimated-reading-time

包简介

Calculate the reading time for any given webpage

README 文档

README

Calculate the estimated reading time of any given webpage.

Installation

You can install the package via composer:

composer require aheenam/estimated-reading-time

Usage

The following command returns the rounded number of estimated minutes to read the given text.

<?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()

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

<?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.

<?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

Testing

To run tests use

$ composer test

Contributing

Security

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

About

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

License

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

统计信息

  • 总下载量: 118
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-02-14