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
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
$identifier
private
string
$identifier
$idKey
private
string
$idKey
= 'id'
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
addItselfAsProperty()
public
addItselfAsProperty(string $key, string $referenceKeyInChild, string $referenceKeyInParent, bool $isNullable) : self
Parameters
- $key : string
- $referenceKeyInChild : string
- $referenceKeyInParent : string
- $isNullable : bool
Return values
selfaddProperty()
public
addProperty(string $key, IModel $model) : self
Parameters
- $key : string
- $model : IModel
Attributes
- #[Override]
Return values
selfgetIdentifier()
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.
getNotNullConstraint()
public
getNotNullConstraint() : INotNullConstraint|null
Attributes
- #[Override]
Return values
INotNullConstraint|null —Whether the content is necessarily specified or can be left omitted.
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
boolprune()
public
prune(array<string|int, mixed> $propertiesToKeep) : self
Parameters
- $propertiesToKeep : array<string|int, mixed>
Attributes
- #[Override]
Return values
selfremoveProperty()
public
removeProperty(string $keyToRemove) : self
Parameters
- $keyToRemove : string
Attributes
- #[Override]
Return values
selfsetIdentifier()
public
setIdentifier(string $newIdentifier) : self
Parameters
- $newIdentifier : string