Skip to content

Commit 61ab509

Browse files
committed
feat(core): add context() method to ContextAware trait
1 parent 4304b27 commit 61ab509

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

packages/core/src/Concerns/ContextAware.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,16 @@ public function setContext(array $context): void
1010
{
1111
$this->context = $context;
1212
}
13+
14+
/**
15+
* Get a value from the context by key.
16+
*
17+
* @param string $key The context key to retrieve
18+
* @param mixed $default Default value if key doesn't exist
19+
* @return mixed The context value or default
20+
*/
21+
public function context(string $key, mixed $default = null): mixed
22+
{
23+
return $this->context[$key] ?? $default;
24+
}
1325
}

0 commit comments

Comments
 (0)