Entity
in package
implements
JsonSerializable, Stringable
Class Entity.
Tags
Interfaces, Classes, Traits and Enums
- JsonSerializable
- Stringable
Table of Contents
- $_jsonFlags : int
- Sets the flags that will be used to encode/decode JSON in internal methods of this Entity class.
- $_jsonVars : array<string|int, mixed>
- Sets the name of the properties that will be visible when this Entity is JSON encoded.
- $_timezone : string
- This timezone is used to convert times in the {@see Entity::toModel()} method.
- __construct() : mixed
- __get() : mixed
- __isset() : bool
- __set() : void
- __toString() : string
- Converts the entity to a JSON string.
- __unset() : void
- jsonSerialize() : stdClass
- toModel() : array<string, scalar>
- Convert the Entity to an associative array accepted by Model methods.
- getObjectVars() : array<string, mixed>
- init() : void
- Used to initialize settings, set custom properties, etc.
- populate() : void
- propertyNotDefined() : OutOfBoundsException
- renderMethodName() : string
- setProperty() : void
- typeHint() : mixed
- Tries to convert the value according to the property type.
- typeHintAplus() : mixed
- Tries to convert the property value using Aplus Framework types.
- typeHintCustom() : mixed
- Override this method to set customizable property types.
- typeHintNative() : mixed
- Tries to convert the property value to native PHP types.
Properties
$_jsonFlags
Sets the flags that will be used to encode/decode JSON in internal methods of this Entity class.
public
int
$_jsonFlags
= \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE | \JSON_PRESERVE_ZERO_FRACTION | \JSON_THROW_ON_ERROR
$_jsonVars
Sets the name of the properties that will be visible when this Entity is JSON encoded.
public
array<string|int, mixed>
$_jsonVars
= []
$_timezone
This timezone is used to convert times in the {@see Entity::toModel()} method.
public
string
$_timezone
= '+00:00'
Note that it must be the same timezone as the database configurations.
Tags
Methods
__construct()
public
__construct(array<string, mixed> $properties) : mixed
Parameters
- $properties : array<string, mixed>
Return values
mixed —__get()
public
__get(string $property) : mixed
Parameters
- $property : string
Tags
Return values
mixed —__isset()
public
__isset(string $property) : bool
Parameters
- $property : string
Return values
bool —__set()
public
__set(string $property, mixed $value) : void
Parameters
- $property : string
- $value : mixed
Tags
Return values
void —__toString()
Converts the entity to a JSON string.
public
__toString() : string
All properties will be included. Please note that sensitive property data may be exposed!
Return values
string —__unset()
public
__unset(string $property) : void
Parameters
- $property : string
Return values
void —jsonSerialize()
public
jsonSerialize() : stdClass
Return values
stdClass —toModel()
Convert the Entity to an associative array accepted by Model methods.
public
toModel() : array<string, scalar>
Tags
Return values
array<string, scalar> —getObjectVars()
protected
getObjectVars() : array<string, mixed>
Return values
array<string, mixed> —init()
Used to initialize settings, set custom properties, etc.
protected
init() : void
Called in the constructor just after the properties be populated.
Return values
void —populate()
protected
populate(array<string, mixed> $properties) : void
Parameters
- $properties : array<string, mixed>
Return values
void —propertyNotDefined()
protected
propertyNotDefined(string $property) : OutOfBoundsException
Parameters
- $property : string
Return values
OutOfBoundsException —renderMethodName()
protected
renderMethodName(string $type, string $property) : string
Parameters
- $type : string
-
get or set
- $property : string
-
Property name
Return values
string —setProperty()
protected
setProperty(string $name, mixed $value) : void
Parameters
- $name : string
- $value : mixed
Return values
void —typeHint()
Tries to convert the value according to the property type.
protected
typeHint(string $propertyType, mixed $value) : mixed
Parameters
- $propertyType : string
- $value : mixed
Return values
mixed —typeHintAplus()
Tries to convert the property value using Aplus Framework types.
protected
typeHintAplus(string $propertyType, string $valueType, mixed $value) : mixed
Parameters
- $propertyType : string
- $valueType : string
- $value : mixed
Tags
Return values
mixed —typeHintCustom()
Override this method to set customizable property types.
protected
typeHintCustom(string $propertyType, string $valueType, mixed $value) : mixed
Parameters
- $propertyType : string
- $valueType : string
- $value : mixed
Return values
mixed —typeHintNative()
Tries to convert the property value to native PHP types.
protected
typeHintNative(string $propertyType, string $valueType, mixed $value) : mixed
Parameters
- $propertyType : string
- $valueType : string
- $value : mixed