vdhicts/read-time

Laravel包,用于确定读取文本所需的时间

v3.0.0 2024-03-17 06:21 UTC

This package is auto-updated.

Last update: 2024-09-17 07:17:12 UTC


README

Laravel包,用于确定文本的阅读时间。

要求

此包至少需要Laravel 11+和PHP 8.2或更高版本。

安装

您可以通过composer安装此包

composer require vdhicts/read-time

使用方法

此包可以使用多种方式。当内容包含HTML时,在计算阅读时间之前会移除HTML。

助手

助手返回阅读此文本所需的时间(以整数分钟为单位)。

read_time($text);
read_time($text, $wordPerMinute);

Blade

Blade指令返回阅读此文本所需的时间(以整数分钟为单位)。

@readTime($text)
@readTime($text, $wordPerMinute)

直接使用

类提供了更多功能。

use Vdhicts\ReadTime\ReadTime;

$readTime = new ReadTime($text);
// OR $readTime = new ReadTime($text, $wordsPerMinute);
$readTime->minutes(); // the amount of minutes (as integer) it should take to read
$readTime->seconds(); // the amount of seconds (as integer) it should take to read
$readTime->wordCount(); // the amount of words (as integer) found in the text

自定义配置

使用以下命令发布配置

php artisan vendor:publish --provider="Vdhicts\ReadTime\ReadTimeServiceProvider"

测试

单元测试位于tests文件夹中。运行命令:

composer test

如果您想生成一个代码覆盖率报告,该报告将在build/report文件夹中生成。运行命令:

composer test-coverage

贡献

欢迎任何贡献,但应满足PSR-12标准,并请为每个功能/错误创建一个pull request。作为回报,您将被列为贡献者。

安全

如果您在此或其他Vdhicts包中发现了任何安全相关的问题,请通过security@vdhicts.nl发送电子邮件,而不是使用问题跟踪器。

支持

如果您在使用此包或关于此包有任何问题,请随时在GitHub上提交问题。

许可

此包是开源软件,许可证为MIT许可证

关于Vdhicts

Vdhicts是我个人的公司名称,我在该公司作为自由职业者工作。Vdhicts为企业和教育机构开发和实施IT解决方案。