Skip to content

Commit

Permalink
refactor: improve getContextId method
Browse files Browse the repository at this point in the history
  • Loading branch information
epessine committed Jun 1, 2024
1 parent 76d514b commit 4e27cee
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/VesselManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 4e27cee

Please sign in to comment.