Skip to content

Instantly share code, notes, and snippets.

@Vasary
Created March 19, 2021 10:17
Show Gist options
  • Save Vasary/246a7a9343aa26a27bceb94ae78aca0a to your computer and use it in GitHub Desktop.
Save Vasary/246a7a9343aa26a27bceb94ae78aca0a to your computer and use it in GitHub Desktop.
<?php
namespace Infrastructure\Generator;
use Domain\Generator\TraceIdGeneratorInterface;
use Domain\GUIDGenerator\GUIDGeneratorInterface;
final class TraceIdProvider implements TraceIdGeneratorInterface
{
private $generator;
private $traceId;
public function __construct(GUIDGeneratorInterface $generator)
{
$this->generator = $generator;
$this->traceId = $this->generator->v4();
}
public function set(string $traceId): void
{
$this->traceId = $traceId;
}
public function get(): string
{
return $this->traceId;
}
public function reset(): void
{
$this->traceId = $this->generator->v4();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment