lcobucci/clock
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
psr/clock | 1.0.0 | 2.95 kB | MIT | prod |
The lcobucci/clock package is essentially a clock abstraction. Its purpose is to decouple projects from the DateTimeImmutable
instantiation method, thereby facilitating the testing process. This package can return the current system time based on a specific timezone, or it can return a fixed time (for testing) when using the FrozenClock
function.
The lcobucci/clock package can be installed and used easily. To install this PHP composer package, you can use the following command in your terminal:
composer require lcobucci/clock
Usage examples show how this package can be incorporated into your code to retrieve the current time or a specific time. For example:
// import the Lcobucci\Clock namespace
use Lcobucci\Clock\SystemClock;
use Lcobucci\Clock\FrozenClock;
// Create an object that will return the current time based on the given timezone
$clock = new SystemClock(new DateTimeZone('America/Sao_Paulo'));
// Test object that always returns a fixed time object
$clock = new FrozenClock(new DateTimeImmutable('2017-05-07 18:49:30'));
// Or creating a frozen clock from the current time on UTC (uncomment to use)
// $clock = FrozenClock::fromUTC();
The lcobucci/clock package does not have a specific documentation page, but you can find further guidance on how to use it on the official GitHub page. There, you can view code examples and general package information that explain the purpose and functions of the lcobucci/clock package in detail. You can also find official digital badges that provide information about the build status, code coverage, and version details of this Composer package.