ttrss/vendor/open-telemetry/sdk/Common/Time/ClockFactory.php

31 lines
620 B
PHP
Raw Permalink Normal View History

2023-10-20 14:12:29 +00:00
<?php
declare(strict_types=1);
namespace OpenTelemetry\SDK\Common\Time;
final class ClockFactory implements ClockFactoryInterface
{
private static ?ClockInterface $default = null;
public static function create(): self
{
return new self();
}
public function build(): ClockInterface
{
return new SystemClock();
}
public static function getDefault(): ClockInterface
{
return self::$default ?? self::$default = self::create()->build();
}
public static function setDefault(?ClockInterface $clock): void
{
self::$default = $clock;
}
}