diff options
Diffstat (limited to 'vendor/open-telemetry/sdk/Common/Time/ClockFactory.php')
-rw-r--r-- | vendor/open-telemetry/sdk/Common/Time/ClockFactory.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/vendor/open-telemetry/sdk/Common/Time/ClockFactory.php b/vendor/open-telemetry/sdk/Common/Time/ClockFactory.php new file mode 100644 index 000000000..33f4364f6 --- /dev/null +++ b/vendor/open-telemetry/sdk/Common/Time/ClockFactory.php @@ -0,0 +1,30 @@ +<?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; + } +} |