echovick / helper-utilities
一个提供开发者可以在其项目中使用的实用函数集合的包。它范围广泛,包括各种类型的辅助函数,如节流或速率限制、尝试、字符串和数字操作。
v1.0.0
2024-05-05 15:35 UTC
Requires
- illuminate/cache: ^9.0
- illuminate/support: ^9.0
- nesbot/carbon: ^2.72
README
Echoutilities 是由 Echovick 开发的 PHP 实用程序包,提供各种辅助函数,以简化 PHP 应用程序中的常见任务。
安装
您可以通过 Composer 安装 Echoutilities。在您的终端中运行以下命令
composer require echovick/helper-utilities
用法
目前,Echoutilities 包括 ThrottleHelper
类,允许您根据用户 ID 和函数名节流函数。
ThrottleHelper
ThrottleHelper
类提供了一种限制用户在指定时间范围内调用函数的速率的方法。
示例用法
use App\Helpers\ThrottleHelper; // Define your function $myFunction = function() { // Your function logic goes here }; // Throttle the function $result = ThrottleHelper::throttle($myFunction, 15, 'myFunction', $userId); // Check the result if (is_callable($result)) { // Function was executed successfully } else { // Function was throttled, handle accordingly echo $result; // Example: "Please try again in 10 seconds." }
文档
有关如何使用 Echoutilities 的更详细文档,请参阅源代码中的 PHPDoc 注释或访问 GitHub 仓库。
贡献
欢迎为 Echoutilities 贡献!如果您有任何建议、改进或要添加的新功能,请打开一个问题或提交一个 pull request 到 GitHub 仓库。
许可
Echoutilities 是开源软件,根据 MIT 许可证 许可。