Download the PHP package ayup-creative/duration without Composer
On this page you can find all versions of the php package ayup-creative/duration. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ayup-creative/duration
More information about ayup-creative/duration
Files in ayup-creative/duration
Package duration
Short Description Carbon-style mutable and immutable Duration value objects with Laravel support
License MIT
Informations about the package duration
Duration
Carbon-style mutable and immutable Duration value objects with Laravel support. This package provides a simple way to handle durations of time (hours, minutes, seconds) without the complexity of dates.
Installation
You can install the package via composer:
Usage
The package provides two main classes: Duration (mutable) and DurationImmutable (immutable).
Creation
Accessing Units
You can access the total time in various units:
You can also get the individual parts of a decomposed duration:
Arithmetic
Comparisons
Formatting & Humanization
TimeDelta (Negative Durations)
While Duration and DurationImmutable are always positive (clamped to 0), TimeDelta allows for negative durations, perfect for representing differences.
Laravel Support
The package includes Eloquent casts for easy integration with your models.
Development
This package uses pre-commit to maintain code quality. To set up your local development environment:
- Install pre-commit:
pip install pre-commit(or your preferred method) - Install the git hooks:
pre-commit install --hook-type pre-commit --hook-type commit-msg
The hooks will automatically run PHPUnit and validate your commit messages against Conventional Commits.
Testing
License
The MIT License (MIT). Please see License File for more information.