sifex / sla-timer
A PHP package for calculating & tracking the Service Level Agreement completion timings
Fund package maintenance!
sifex
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
- dev-main
- v0.1.6.5
- v0.1.6.4
- v0.1.6.3
- v0.1.6.2
- v0.1.6.1
- v0.1.6
- v0.1.5
- v0.1.4
- v0.1.3-alpha
- v0.1.2-alpha
- v0.1.1-alpha
- v0.1.0-alpha
- v0.0.3-beta
- v0.0.2-beta
- v0.0.1-beta
- dev-dependabot/npm_and_yarn/multi-a58c0a3040
- dev-dependabot/npm_and_yarn/nanoid-3.3.8
- dev-dependabot/npm_and_yarn/multi-09d1b7077e
- dev-dependabot/npm_and_yarn/multi-d5a78f2728
- dev-fix/remove-carbon-sig
This package is auto-updated.
Last update: 2024-12-12 21:44:00 UTC
README
A PHP package for calculating & tracking the Service Level Agreement completion timings.
Features
- 🕚 Easy schedule building
- ‼️ Defined breaches
- 🏝 Holiday & Paused Durations
Installation
You can install the sla-timer
via composer:
composer require sifex/sla-timer
Getting Started
The best place to get started with SLA timer is to head over to the ✨ SLA Timer Getting Started Documentation.
Example Usage
To create a new SLA Timer, we can start by defining our SLA Schedule:
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() );
We can define out breaches by calling the addBreaches
method on our SLA
/** * Define two breaches, one at 24 hours, and the next at 100 hours */ $sla->addBreaches([ new SLABreach('First Response', '24h'), new SLABreach('Resolution', '100h'), ]);
Now that our SLA Schedule and SLA Breaches are defined, all we have to do is give our subject "creation time" – or our SLA start time – to either the status
method, or the duration
method.
// 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
Testing
composer test
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.