1. Go to this page and download the library: Download a50/clock library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
a50 / clock example snippets
declare(strict_types=1);
namespace Project\Reviews\Application\AddReview;
use Psr\Clock\ClockInterface;
use Project\Reviews\Domain\Review;
// ...
final class Handler
{
private ClockInterface $clock;
public function __construct(
ClockInterface $clock,
// ...
) {
$this->clock = $clock;
// ...
}
public function __invoke(Command $command): void
{
$review = Review::add(
// ...
$this->clock->now(),
);
// ...
}
}
declare(strict_types=1);
$clock = new TimeZoneAwareClock(new DateTimeZone('Europe/Minsk'));
$now = $clock->now();
declare(strict_types=1);
use A50\Container\ServiceProvider;
use A50\Clock\ClockConfig;
new class implements ServiceProvider {
// ...
/**
* @inheritDoc
*/
public static function getExtensions(): array
{
return [
ClockConfig::class => static function ($config, ContainerInterface $container): stdClass {
$config->withTimezone('Europe/Minsk');
return $config;
}
];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.