Documentation

EntityModel extends ArrayModel
in package

FinalYes

An ArrayModel where there must be a property identifying the entity amongst others entities of the same model, as well as the model among other models.

Tags
todo

Disallow sub EntityModel sub properties that are not contained within a ForeignEntityModel?

Check all property keys are snake_case.

Table of Contents

Properties

$properties  : array<string|int, mixed>
$identifier  : string
$idKey  : string

Methods

__construct()  : mixed
addItselfAsProperty()  : self
addProperty()  : self
getIdentifier()  : string
getIdKey()  : string
getNotNullConstraint()  : INotNullConstraint|null
getProperties()  : array<string, IModel>
This guarantees each property has a unique key in the context of the model.
isNullable()  : bool
Shorter way to check whether the content can be null.
prune()  : self
removeProperty()  : self
setIdentifier()  : self

Properties

$properties

protected array<string|int, mixed> $properties

Methods

__construct()

public __construct(string $identifier, array<string, IModel$properties[, string $idKey = 'id' ][, bool $isNullable = false ]) : mixed
Parameters
$identifier : string

A snake_case identifier for the model.

$properties : array<string, IModel>

An associative list of properties.

$idKey : string = 'id'

The key of the property identifying entities of the same model.

$isNullable : bool = false

Whether the entity is nullable.

Tags
todo

Check that property keys are strings.

addItselfAsProperty()

public addItselfAsProperty(string $key, string $referenceKeyInChild, string $referenceKeyInParent, bool $isNullable) : self
Parameters
$key : string
$referenceKeyInChild : string
$referenceKeyInParent : string
$isNullable : bool
Return values
self

addProperty()

public addProperty(string $key, IModel $model) : self
Parameters
$key : string
$model : IModel
Attributes
#[Override]
Return values
self

getIdentifier()

public getIdentifier() : string
Return values
string

An identifier for the model.

getIdKey()

public getIdKey() : string
Return values
string

The key of the model property that serves as its primary key.

getProperties()

This guarantees each property has a unique key in the context of the model.

public getProperties() : array<string, IModel>
Return values
array<string, IModel>

An associative array of properties.

isNullable()

Shorter way to check whether the content can be null.

public isNullable() : bool
Attributes
#[Override]
Return values
bool

prune()

public prune(array<string|int, mixed> $propertiesToKeep) : self
Parameters
$propertiesToKeep : array<string|int, mixed>
Attributes
#[Override]
Return values
self

removeProperty()

public removeProperty(string $keyToRemove) : self
Parameters
$keyToRemove : string
Attributes
#[Override]
Return values
self

setIdentifier()

public setIdentifier(string $newIdentifier) : self
Parameters
$newIdentifier : string
Return values
self
On this page

Search results