aheenam/estimated-reading-time
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.
aheenam/estimated-reading-time 适用场景与选型建议
aheenam/estimated-reading-time 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 118 次下载、GitHub Stars 达 10, 最近一次更新时间为 2018 年 02 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 aheenam/estimated-reading-time 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 aheenam/estimated-reading-time 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 118
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-02-14