final class SessionNamespace (View source)

Isolates a logical key space inside one parent session without owning its lifecycle.

Constants

private SESSION_KEY_PREFIX

Methods

__construct(SessionInterface $session, string $name)

Connects a validated logical namespace to the parent session's shared lifecycle.

bool
has(string $key)

Checks whether this namespace contains a value for the key.

bool
mixed
get(string $key, mixed $default = null)

Returns a namespaced value or the caller-provided fallback.

mixed
void
set(string $key, mixed $value)

Stores or replaces one value without changing other namespaces.

void
void
remove(string $key)

Removes one value while preserving the rest of this namespace.

void
array
all()

Returns all normalized values without mutating this namespace.

array
void
clear()

Removes this complete namespace without affecting other parent session data.

void

Details

__construct

__construct(SessionInterface $session, string $name)

Connects a validated logical namespace to the parent session's shared lifecycle.

Parameters

SessionInterface $session
string $name

Exceptions

InvalidArgumentException

has

bool has(string $key)

Checks whether this namespace contains a value for the key.

Parameters

string $key

Return Value

bool

get

mixed get(string $key, mixed $default = null)

Returns a namespaced value or the caller-provided fallback.

Parameters

string $key
mixed $default

Return Value

mixed

set

void set(string $key, mixed $value)

Stores or replaces one value without changing other namespaces.

Parameters

string $key
mixed $value

Return Value

void

remove

void remove(string $key)

Removes one value while preserving the rest of this namespace.

Parameters

string $key

Return Value

void

all

array all()

Returns all normalized values without mutating this namespace.

Return Value

array

clear

void clear()

Removes this complete namespace without affecting other parent session data.

Return Value

void