phpEZ v0.4.0

Sexable

Trait Sexable: Provides session persistence helpers for Model/Obj classes via Sex.

Classes utilizing this trait should ensure __serialize() and __unserialize() are implemented to handle state serialization safely.

Table of Contents

Properties

$_sex  : Sex|null

Methods

fromSex()  : static|null
Retrieve a model instance from the session.
setSex()  : void
Set a custom Sex session handler for this specific model class.
toSex()  : static
Store this model instance in the session.
getSex()  : Sex

Properties

$_sex

private static Sex|null $_sex = \null

Methods

fromSex()

Retrieve a model instance from the session.

public static fromSex([string|null $key = null ]) : static|null
Parameters
$key : string|null = null

Optional suffix for the session key.

Return values
static|null

Restored model instance or null if not found.

setSex()

Set a custom Sex session handler for this specific model class.

public static setSex(Sex $sex) : void
Parameters
$sex : Sex

toSex()

Store this model instance in the session.

public toSex([string|null $key = null ]) : static

If used on a model that is not persisted (no ID) or is dirty, an HTTPException will be thrown.

Parameters
$key : string|null = null

Optional suffix for the session key.

Tags
throws
HTTPException

If model is unpersisted or dirty.

Return values
static

Returns $this for fluent chaining.

getSex()

protected static getSex() : Sex
Return values
Sex
On this page

Search results