headsnet / carbon-clock
A clock interface and implementation using the Carbon date manipulation library
Installs: 3 593
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >8.1
- nesbot/carbon: ^2.38 || ^3.0
Requires (Dev)
- phpstan/phpstan: ^1.8
- phpunit/phpunit: ^8.0 || ^9.0
- symplify/easy-coding-standard: ^11
README
Carbon Clock
A clock interface and implementation using the Carbon date manipulation library.
Usage
Wherever you need access to the system time, inject a clock implementation by typehinting against the Clock
interface.
In production environments, create a service from the SystemClock
, and arrange for this to be injected wherever the
Clock
interface is used.
During testing, you can substitute the FrozenClock
implementation, which will provide additional features for freezing
time, and otherwise manipulating it to make testing time sensitive code much easier.
Contributing
Contributions are welcome. Please submit pull requests with one fix/feature per pull request.
Composer scripts are configured for your convenience:
> composer test # Run test suite
> composer cs # Run coding standards checks
> composer cs-fix # Fix coding standards violations
> composer static # Run static analysis with Phpstan
Licence
This code is released under the MIT licence. Please see the LICENSE file for more information.