si-flex/sla-timer

用于计算和跟踪服务水平协议完成时间的 PHP 包

v0.1.6.5 2022-07-28 15:03 UTC

README

Logo for SLA Timer

Latest Version on Packagist Total Downloads GitHub Actions

一个用于计算和跟踪服务水平协议完成时间的 PHP 包。

功能

  • 🕚 简单的日程安排构建
  • ‼️ 定义违约
  • 🏝 假日和暂停时间
Hi, I'm Alex & I'm currently looking for a Laravel job. Please reach out to me via twitter, or click this link.

安装

您可以通过 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)。有关更多信息,请参阅 许可文件