Entity class abstract

Framework\MVC\Entity

Class Entity.

Implements: JsonSerializable, Stringable

Defined in libraries/mvc/src/Entity.php

Properties #

$_jsonFlags
Sets the flags that will be used to encode/decode JSON in internal methods of this Entity class.
$_jsonVars
Sets the name of the properties that will be visible when this Entity is JSON encoded.
$_timezone
This timezone is used to convert times in the {@see Entity::toModel()} method.

$_jsonFlags

public int $_jsonFlags = 4195648

Sets the flags that will be used to encode/decode JSON in internal methods of this Entity class.

$_jsonVars

public array $_jsonVars = array ( )

Sets the name of the properties that will be visible when this Entity is JSON encoded.

$_timezone

public string $_timezone = '+00:00'

This timezone is used to convert times in the {@see Entity::toModel()} method.

Methods #

__construct()
-
__get()
-
__isset()
-
__set()
-
__toString()
Converts the entity to a JSON string. All properties will be included. Please note that sensitive property data may be exposed!
__unset()
-
jsonSerialize()
-
toModel()
Convert the Entity to an associative array accepted by Model methods.
getObjectVars()
-
init()
Used to initialize settings, set custom properties, etc. Called in the constructor just after the properties be populated.
populate()
-
propertyNotDefined()
-
renderMethodName()
-
setProperty()
-
typeHint()
Tries to convert the value according to the property type.
typeHintCustom()
Override this method to set customizable property types.
typeHintNative()
Tries to convert the property value to native PHP types.
typeHintWebisters()
Tries to convert the property value using Webisters types.

__construct()

public function __construct(array $properties)
Parameters
  • array $properties

__get()

public function __get(string $property): mixed
Parameters
  • string $property
Returns mixed
throws
OutOfBoundsException If property is not defined

__isset()

public function __isset(string $property): bool
Parameters
  • string $property
Returns bool

__set()

public function __set(string $property, mixed $value): void
Parameters
  • string $property
  • mixed $value
Returns void
throws
OutOfBoundsException If property is not defined

__toString()

public function __toString(): string

Converts the entity to a JSON string. All properties will be included. Please note that sensitive property data may be exposed!

Returns string

__unset()

public function __unset(string $property): void
Parameters
  • string $property
Returns void

jsonSerialize()

public function jsonSerialize(): stdClass
Returns stdClass

toModel()

public function toModel(): array

Convert the Entity to an associative array accepted by Model methods.

Returns array
throws
Exception in case of error creating DateTimeZone
throws
JsonException in case of error while encoding/decoding JSON

getObjectVars()

protected function getObjectVars(): array
Returns array

init()

protected function init(): void

Used to initialize settings, set custom properties, etc. Called in the constructor just after the properties be populated.

Returns void

populate()

protected function populate(array $properties): void
Parameters
  • array $properties
Returns void

propertyNotDefined()

protected function propertyNotDefined(string $property): OutOfBoundsException
Parameters
  • string $property
Returns OutOfBoundsException

renderMethodName()

protected function renderMethodName(string $type, string $property): string
Parameters
  • string $type - get or set
  • string $property - Property name
Returns string

setProperty()

protected function setProperty(string $name, mixed $value): void
Parameters
  • string $name
  • mixed $value
Returns void

typeHint()

protected function typeHint(string $propertyType, mixed $value): mixed

Tries to convert the value according to the property type.

Parameters
  • string $propertyType
  • mixed $value
Returns mixed

typeHintCustom()

protected function typeHintCustom(string $propertyType, string $valueType, mixed $value): mixed

Override this method to set customizable property types.

Parameters
  • string $propertyType
  • string $valueType
  • mixed $value
Returns mixed

typeHintNative()

protected function typeHintNative(string $propertyType, string $valueType, mixed $value): mixed

Tries to convert the property value to native PHP types.

Parameters
  • string $propertyType
  • string $valueType
  • mixed $value
Returns mixed

typeHintWebisters()

protected function typeHintWebisters(string $propertyType, string $valueType, mixed $value): mixed

Tries to convert the property value using Webisters types.

Parameters
  • string $propertyType
  • string $valueType
  • mixed $value
Returns mixed
throws
Exception