https://github.com/sifex/sla-timer
A PHP package for calculating & tracking the Service Level Agreement completion timings
https://github.com/sifex/sla-timer
hacktoberfest php php8 sla timer
Last synced: 7 months ago
JSON representation
A PHP package for calculating & tracking the Service Level Agreement completion timings
- Host: GitHub
- URL: https://github.com/sifex/sla-timer
- Owner: sifex
- License: mit
- Created: 2022-07-15T22:49:38.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-21T20:57:56.000Z (9 months ago)
- Last Synced: 2025-03-09T14:06:01.693Z (7 months ago)
- Topics: hacktoberfest, php, php8, sla, timer
- Language: PHP
- Homepage: https://sifex.github.io/sla-timer/
- Size: 2.03 MB
- Stars: 33
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
[](https://packagist.org/packages/sifex/sla-timer)
[](https://packagist.org/packages/sifex/sla-timer)
A PHP package for calculating & tracking the Service Level Agreement completion timings.
### Features
- 🕚 Easy schedule building
- ‼️ Defined breaches
- 🏝 Holiday & Paused Durations---
---
## InstallationYou can install the `sla-timer` via composer:
```bash
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](https://sifex.github.io/sla-timer/guide/getting_started).
## Example Usage
To create a new SLA Timer, we can start by defining our SLA Schedule:
```php
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
```php
/**
* 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.
```php
// 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
```bash
composer test
```## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## Credits
- [Alex](https://github.com/sifex)
- [All Contributors](../../contributors)## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.