diff --git a/src/VesselManager.php b/src/VesselManager.php index b7c81ab..365b61f 100644 --- a/src/VesselManager.php +++ b/src/VesselManager.php @@ -13,15 +13,15 @@ class VesselManager public static function getContextId(): string { - if (isset(self::$contextId)) { - return self::$contextId; - } - /** @var Request $request */ $request = request(); - /** @var string $contextId */ - $contextId = $request->header(self::CONTEXT_HEADER, Str::random(20)); + /** @var ?string $contextId */ + $contextId = $request->header(self::CONTEXT_HEADER); + + if ($contextId !== null) { + return $contextId; + } - return self::$contextId = $contextId; + return self::$contextId ??= Str::random(20); } }