This repository was archived by the owner on Sep 27, 2021. It is now read-only.

Description
Add the option to save a simple PHP object into the database. For instance creating a simple Email object which can only contain a valid email address.
Such class would look something like the following:
class Email extends PersistenceObject {
/** @var string **/
protected $email;
/**
* @param string $email;
*/
public function __construct($email) {
$this->assertValidEmail($email);
$this->email = $email;
}
public function getValue() {
return $this->email;
}
}
abstract class PersistenceObject {
abstract public function __construct($value);
abstract public function getValue();
}
The objects should require one required constructor argument and implement the getValue method.
When defining a model the definition would look something like:
protected static $persistent_attributes = [
'email' => [T::Object, true, Email::class],
];
Or just, where the orm checks if the type is instantiable (subclass of PersistenceObject)
protected static $persistent_attributes = [
'email' => [Email::class],
];