Skip to content
PHP Ecosystem
Explore

BaseModel

API reference › Model › BaseModel

abstract classUIAwesome\Model\BaseModel
ImplementsModelInterface
Sourcesrc/BaseModel.php
1 subclass

Base implementation of ModelInterface.

MethodDescriptionDefined by
add()Registers a property and its supported types.BaseModel
getData()Returns the raw input retained after loading.BaseModel
getModelName()Returns the model class name used as the default input scope.BaseModel
getNames()Returns property names, expanding nested models with dot notation.BaseModel
getTypes()Returns collected property types indexed by property name.BaseModel
getValue()Returns a property value, including nested model paths.BaseModel
has()Checks whether a property or nested model path exists.BaseModel
isEmpty()Checks whether the loaded raw input is empty.BaseModel
isType()Checks whether a property supports the requested type.BaseModel
load()Assigns scoped or unscoped input and retains its raw keys.BaseModel
setValue()Assigns a property value using its attributes and type metadata.BaseModel
setValues()Assigns input values while excluding the selected property names.BaseModel
toArray()Exports property values with optional top-level snake_case keys.BaseModel
public function add(string $property, string|array $type): void

Registers a property and its supported types.

Parameters

ParameterTypeDescription
$propertystring
$typestring|array
public function getData(): array

Returns the raw input retained after loading.

Returns

array

public function getModelName(): string

Returns the model class name used as the default input scope.

Returns

string

public function getNames(): array

Returns property names, expanding nested models with dot notation.

Returns

array

public function getTypes(): array

Returns collected property types indexed by property name.

Returns

array

public function getValue(string $property): mixed

Returns a property value, including nested model paths.

Parameters

ParameterTypeDescription
$propertystring

Returns

mixed

public function has(string $property): bool

Checks whether a property or nested model path exists.

Parameters

ParameterTypeDescription
$propertystring

Returns

bool

public function isEmpty(): bool

Checks whether the loaded raw input is empty.

Returns

bool

public function isType(string $property, string $type): bool

Checks whether a property supports the requested type.

Parameters

ParameterTypeDescription
$propertystring
$typestring

Returns

bool

public function load(iterable $data, string|null $modelName = null): bool

Assigns scoped or unscoped input and retains its raw keys.

Parameters

ParameterTypeDescription
$dataiterable
$modelNamestring|null

Returns

bool

public function setValue(string $property, mixed $value): void

Assigns a property value using its attributes and type metadata.

Parameters

ParameterTypeDescription
$propertystring
$valuemixed
public function setValues(array $data, array $except = []): void

Assigns input values while excluding the selected property names.

Parameters

ParameterTypeDescription
$dataarray
$exceptarray
public function toArray(bool $snakeCase = false, array $exceptProperties = []): array

Exports property values with optional top-level snake_case keys.

Parameters

ParameterTypeDescription
$snakeCasebool
$exceptPropertiesarray

Returns

array