Download the PHP package php-architecture-kit/clock without Composer
On this page you can find all versions of the php package php-architecture-kit/clock. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download php-architecture-kit/clock
More information about php-architecture-kit/clock
Files in php-architecture-kit/clock
Download php-architecture-kit/clock
More information about php-architecture-kit/clock
Files in php-architecture-kit/clock
Vendor php-architecture-kit
Package clock
Short Description Another Clock implementation but if you allow the PHP Architecture library to be used on your domains, then you may prefer `new SystemClock` from that library rather than any other.
License MIT
Homepage https://github.com/php-architecture-kit/clock
Package clock
Short Description Another Clock implementation but if you allow the PHP Architecture library to be used on your domains, then you may prefer `new SystemClock` from that library rather than any other.
License MIT
Homepage https://github.com/php-architecture-kit/clock
Please rate this library. Is it a good library?
Informations about the package clock
php-architecture-kit/clock
PSR-20 Clock implementations for PHP applications. Provides testable time abstractions for domain-driven design and clean architecture.
Features
- PSR-20 compliant - Implements
Psr\Clock\ClockInterface - Testable -
FrozenClockfor deterministic unit tests - Timezone-aware -
LocalizedClockfor specific timezones - Zero dependencies - Only requires
psr/clock - PHP 7.4+ - Compatible with legacy and modern PHP
Installation
Quick Start
Clock Implementations
SystemClock
Returns the current system time. Use in production code.
FrozenClock
Returns a fixed time. Ideal for unit testing.
LocalizedClock
Returns current time in a specific timezone.
Usage in Domain Services
Inject ClockInterface instead of calling new \DateTimeImmutable() directly:
Production Configuration
Testing
Comparison
| Clock | Use Case | Time Changes |
|---|---|---|
SystemClock |
Production | Yes |
FrozenClock |
Unit tests | No |
LocalizedClock |
Timezone-specific apps | Yes |
API Reference
SystemClock
| Method | Description |
|---|---|
now(): DateTimeImmutable |
Returns current system time |
FrozenClock
| Method | Description |
|---|---|
__construct(DateTimeImmutable $frozenAt) |
Create with fixed time |
at(DateTimeImmutable $frozenAt): self |
Factory: create with fixed time |
fromNow(): self |
Factory: freeze current time |
now(): DateTimeImmutable |
Returns the frozen time |
LocalizedClock
| Method | Description |
|---|---|
__construct(DateTimeZone $timeZone) |
Create with timezone |
utc(): self |
Factory: create UTC clock |
now(): DateTimeImmutable |
Returns current time in timezone |
Testing
Package is tested with PHPUnit in the php-architecture-kit/workspace project.
License
MIT
All versions of clock with dependencies
PHP Build Version
Package Version
The package php-architecture-kit/clock contains the following files
Loading the files please wait ...