si-flex / sla-timer
用于计算和跟踪服务水平协议完成时间的 PHP 包
v0.1.6.5
2022-07-28 15:03 UTC
Requires
- php: ^8.0
- cmixin/enhanced-period: ^1.2
- illuminate/collections: ^8|^9|^10|^11
- nesbot/carbon: ^2
- spatie/period: ^2
Requires (Dev)
- laravel/pint: ^1.0
- pestphp/pest: ^1.21
- phpstan/phpstan: ^1.8
- phpunit/phpunit: ^9.0
- spatie/invade: ^1.1
- spatie/pest-plugin-test-time: ^1.1
This package is auto-updated.
Last update: 2024-09-24 16:54:10 UTC
README
一个用于计算和跟踪服务水平协议完成时间的 PHP 包。
功能
- 🕚 简单的日程安排构建
- ‼️ 定义违约
- 🏝 假日和暂停时间
安装
您可以通过 composer 安装 sla-timer
composer require sifex/sla-timer
入门指南
要开始使用 SLA 计时器,请访问 ✨ SLA Timer 入门指南文档。
示例用法
要创建一个新的 SLA 计时器,我们首先定义我们的 SLA 日程
require 'vendor/autoload.php'; use Sifex\SlaTimer\SLA; use Sifex\SlaTimer\SLABreach; use Sifex\SlaTimer\SLASchedule; /** * Create a new SLA between 9am and 5:30pm weekdays */ $sla = SLA::fromSchedule( SLASchedule::create()->from('09:00:00')->to('17:30:00') ->onWeekdays() );
我们可以通过在 SLA 上调用 addBreaches
方法来定义我们的违约
/** * Define two breaches, one at 24 hours, and the next at 100 hours */ $sla->addBreaches([ new SLABreach('First Response', '24h'), new SLABreach('Resolution', '100h'), ]);
现在我们的 SLA 日程 和 SLA 违约 已经定义,我们只需要提供我们的 主题 的 "创建时间" - 或者我们的 SLA 开始时间 - 给 status
方法或 duration
方法。
// Given the time now is 14:00:00 29-07-2022 $status = $sla->status('05:35:40 25-07-2022'); // SLAStatus $status->breaches; // [SLABreach] [0: { First Response } ] $duration = $sla->duration('05:35:40 25-07-2022'); // CarbonInterval $duration->forHumans(); // 1 day 15 hours
测试
composer test
贡献
请参阅 CONTRIBUTING 了解详细信息。
鸣谢
许可协议
MIT 许可协议(MIT)。有关更多信息,请参阅 许可文件。