{"$schema":"https://yii2-framework.github.io/docs/reference/reference.schema.json","schemaVersion":1,"package":"model","title":"Model","repository":"https://github.com/ui-awesome/model","ref":"main","commit":"791ee2609f378c3bdc92f64b1bbc0efc8bbddb28","generatedAt":"2026-11-20","url":"https://yii2-framework.github.io/docs/extensions/model/reference/","types":{"UIAwesome\\Model\\Attribute\\Cast":{"kind":"class","modifiers":["final","readonly"],"url":"https://yii2-framework.github.io/docs/extensions/model/reference/attribute/cast/","summary":"Forces custom casting before native property type casting.","properties":{"separator":{"type":"string","description":"Separates string items when casting to an array.","readonly":true},"target":{"type":"string","description":"Identifies the cast type or custom caster class.","readonly":true}},"methods":{"__construct":{"signature":"public function __construct(string $target, string $separator = ',')","summary":"Configures a nonempty cast target and array separator.","params":[{"name":"$target","type":"string","description":"Cast type or custom caster class."},{"name":"$separator","type":"string","default":"','","optional":true,"description":"Nonempty separator for array casts."}],"throws":[{"type":"InvalidArgumentException","description":"When the target or separator is empty."}]}}},"UIAwesome\\Model\\Attribute\\DefaultValue":{"kind":"class","modifiers":["final","readonly"],"url":"https://yii2-framework.github.io/docs/extensions/model/reference/attribute/defaultvalue/","summary":"Applies a runtime default when assigned input is `null` or an empty string.","properties":{"value":{"type":"mixed","description":"Runtime default value.","readonly":true,"promoted":true}},"methods":{"__construct":{"signature":"public function __construct(mixed $value)","summary":"Configures the value applied to `null` or empty-string input.","params":[{"name":"$value","type":"mixed","description":"Runtime default value."}]}}},"UIAwesome\\Model\\Attribute\\DoNotCollect":{"kind":"class","modifiers":["final"],"url":"https://yii2-framework.github.io/docs/extensions/model/reference/attribute/donotcollect/","summary":"Excludes a property from automatic type collection."},"UIAwesome\\Model\\Attribute\\MapFrom":{"kind":"class","modifiers":["final","readonly"],"url":"https://yii2-framework.github.io/docs/extensions/model/reference/attribute/mapfrom/","summary":"Maps a model property from an explicit input key.","properties":{"key":{"type":"string","description":"Identifies the external input key mapped to this property.","readonly":true}},"methods":{"__construct":{"signature":"public function __construct(string $key)","summary":"Configures the external input key.","params":[{"name":"$key","type":"string","description":"Nonempty input key."}],"throws":[{"type":"InvalidArgumentException","description":"When the key is empty."}]}}},"UIAwesome\\Model\\Attribute\\NoSnakeCase":{"kind":"class","modifiers":["final"],"url":"https://yii2-framework.github.io/docs/extensions/model/reference/attribute/nosnakecase/","summary":"Prevents key conversion to snake_case during array serialization."},"UIAwesome\\Model\\Attribute\\Timestamp":{"kind":"class","modifiers":["final"],"url":"https://yii2-framework.github.io/docs/extensions/model/reference/attribute/timestamp/","summary":"Marks a property as a timestamp field initialized on assignment."},"UIAwesome\\Model\\Attribute\\Trim":{"kind":"class","modifiers":["final"],"url":"https://yii2-framework.github.io/docs/extensions/model/reference/attribute/trim/","summary":"Trims leading and trailing whitespace from string input before assignment."},"UIAwesome\\Model\\BaseModel":{"kind":"class","modifiers":["abstract"],"url":"https://yii2-framework.github.io/docs/extensions/model/reference/basemodel/","summary":"Base implementation of `UIAwesome\\Model\\ModelInterface`.","implements":["UIAwesome\\Model\\ModelInterface"],"methods":{"add":{"signature":"public function add(string $property, string|array $type): void","summary":"Registers a property and its supported types.","params":[{"name":"$property","type":"string"},{"name":"$type","type":"string|array"}],"return":{"type":"void"}},"getData":{"signature":"public function getData(): array","summary":"Returns the raw input retained after loading.","return":{"type":"array"}},"getModelName":{"signature":"public function getModelName(): string","summary":"Returns the model class name used as the default input scope.","return":{"type":"string"}},"getNames":{"signature":"public function getNames(): array","summary":"Returns property names, expanding nested models with dot notation.","return":{"type":"array"}},"getTypes":{"signature":"public function getTypes(): array","summary":"Returns collected property types indexed by property name.","return":{"type":"array"}},"getValue":{"signature":"public function getValue(string $property): mixed","summary":"Returns a property value, including nested model paths.","params":[{"name":"$property","type":"string"}],"return":{"type":"mixed"}},"has":{"signature":"public function has(string $property): bool","summary":"Checks whether a property or nested model path exists.","params":[{"name":"$property","type":"string"}],"return":{"type":"bool"}},"isEmpty":{"signature":"public function isEmpty(): bool","summary":"Checks whether the loaded raw input is empty.","return":{"type":"bool"}},"isType":{"signature":"public function isType(string $property, string $type): bool","summary":"Checks whether a property supports the requested type.","params":[{"name":"$property","type":"string"},{"name":"$type","type":"string"}],"return":{"type":"bool"}},"load":{"signature":"public function load(iterable $data, string|null $modelName = null): bool","summary":"Assigns scoped or unscoped input and retains its raw keys.","params":[{"name":"$data","type":"iterable"},{"name":"$modelName","type":"string|null","default":"null","optional":true}],"return":{"type":"bool"}},"setValue":{"signature":"public function setValue(string $property, mixed $value): void","summary":"Assigns a property value using its attributes and type metadata.","params":[{"name":"$property","type":"string"},{"name":"$value","type":"mixed"}],"return":{"type":"void"}},"setValues":{"signature":"public function setValues(array $data, array $except = []): void","summary":"Assigns input values while excluding the selected property names.","params":[{"name":"$data","type":"array"},{"name":"$except","type":"array","default":"[]","optional":true}],"return":{"type":"void"}},"toArray":{"signature":"public function toArray(bool $snakeCase = false, array $exceptProperties = []): array","summary":"Exports property values with optional top-level snake_case keys.","params":[{"name":"$snakeCase","type":"bool","default":"false","optional":true},{"name":"$exceptProperties","type":"array","default":"[]","optional":true}],"return":{"type":"array"}}}},"UIAwesome\\Model\\CastValueInterface":{"kind":"interface","url":"https://yii2-framework.github.io/docs/extensions/model/reference/castvalueinterface/","summary":"Contract for custom value casters used by `#[Cast]`.","methods":{"cast":{"signature":"abstract public function cast(mixed $value): mixed","summary":"Casts the incoming value into a target representation.","params":[{"name":"$value","type":"mixed"}],"return":{"type":"mixed"},"abstract":true}}},"UIAwesome\\Model\\Exception\\Message":{"kind":"enum","url":"https://yii2-framework.github.io/docs/extensions/model/reference/exception/message/","summary":"Represents reusable error message templates for model exceptions.","backingType":"string","cases":{"CAST_SEPARATOR_EMPTY":{"value":"'Cast separator cannot be empty.'","description":"Indicates an empty Cast separator."},"CAST_TARGET_EMPTY":{"value":"'Cast target cannot be empty.'","description":"Indicates an empty Cast target."},"COLLECTOR_MODEL_CLASS_MISMATCH":{"value":"\"Cannot rebind collector for '%s' to model of class '%s'.\"","description":"Indicates an attempt to reuse collector metadata with a different model class."},"DUPLICATE_MAP_FROM_KEY":{"value":"\"Duplicate MapFrom key '%s' in '%s::%s' and '%s::%s'.\"","description":"Indicates duplicate input-key mapping across model properties."},"INVALID_CAST_CLASS":{"value":"\"Cast target '%s' for '%s::%s' must implement '%s'.\"","description":"Indicates cast class does not implement required caster contract."},"INVALID_CAST_TARGET":{"value":"\"Invalid Cast target '%s' for '%s::%s'.\"","description":"Indicates unsupported cast target for a model property."},"INVALID_DATE_TIME_STRING":{"value":"\"Invalid date/time string '%s' for type '%s'.\"","description":"Indicates invalid string input for date/time object casting."},"MAP_FROM_KEY_EMPTY":{"value":"'MapFrom key cannot be empty.'","description":"Indicates an empty MapFrom input key."},"READONLY_PROPERTY_ALREADY_INITIALIZED":{"value":"\"Cannot overwrite initialized readonly property: '%s::%s'.\"","description":"Indicates attempts to overwrite an initialized readonly property."},"UNDEFINED_PROPERTY":{"value":"\"Undefined property: '%s'.\"","description":"Indicates an undefined property without model class context."},"UNDEFINED_PROPERTY_WITH_CLASS":{"value":"\"Undefined property: '%s::%s'.\"","description":"Indicates an undefined property including model class context."}},"methods":{"getMessage":{"signature":"public function getMessage(int|string ...$argument): string","summary":"Returns the formatted message string for the error case.","params":[{"name":"$argument","type":"int|string","optional":true,"variadic":true,"description":"Values to insert into the message template."}],"return":{"type":"string","description":"Formatted error message with interpolated arguments."}}}},"UIAwesome\\Model\\ModelInterface":{"kind":"interface","url":"https://yii2-framework.github.io/docs/extensions/model/reference/modelinterface/","summary":"Interface implemented by classes supporting model data binding.","methods":{"add":{"signature":"abstract public function add(string $property, array|string $type): void","summary":"Adds a new property to the model.","params":[{"name":"$property","type":"string","description":"Property name."},{"name":"$type","type":"array|string","description":"Property type. This can be a string or an array of strings representing the property type. If an array is given, the property is considered to be multi-valued and the property value should be an array of values of the given types."}],"return":{"type":"void"},"abstract":true},"getData":{"signature":"abstract public function getData(): array","summary":"Returns the raw data for the model.","return":{"type":"array","description":"Raw data for the model."},"abstract":true},"getModelName":{"signature":"abstract public function getModelName(): string","summary":"Returns the model name that this model class should use.","return":{"type":"string","description":"Model name class, without a namespace part or empty string when class is anonymous. `load()`"},"abstract":true},"getNames":{"signature":"abstract public function getNames(): list<string>","summary":"Returns the list of property names.","return":{"type":"list<string>","description":"List of property names."},"abstract":true},"getTypes":{"signature":"abstract public function getTypes(): array","summary":"Returns the list of property types indexed by property names.","return":{"type":"array","description":"List of property types indexed by property names."},"abstract":true},"getValue":{"signature":"abstract public function getValue(string $property): mixed","summary":"Returns the value (raw data) for the specified property.","params":[{"name":"$property","type":"string","description":"Property name."}],"return":{"type":"mixed","description":"Value (raw data) for the specified property."},"abstract":true},"has":{"signature":"abstract public function has(string $property): bool","summary":"Checks if the model has the specified property.","params":[{"name":"$property","type":"string","description":"Property name."}],"return":{"type":"bool","description":"`true` if the model has the specified property, `false` otherwise."},"abstract":true},"isEmpty":{"signature":"abstract public function isEmpty(): bool","summary":"Whether the model has no loaded raw data.","return":{"type":"bool","description":"`true` if the model has no loaded raw data, `false` otherwise."},"abstract":true},"isType":{"signature":"abstract public function isType(string $property, string $type): bool","summary":"Checks if the property is of the specified type.","params":[{"name":"$property","type":"string","description":"Property name."},{"name":"$type","type":"string","description":"Type name."}],"return":{"type":"bool","description":"`true` if the property is of the specified type, `false` otherwise."},"abstract":true},"load":{"signature":"abstract public function load(iterable $data, string|null $modelName = null): bool","summary":"Populates the model with input data.","params":[{"name":"$data","type":"iterable","description":"Data array to load, typically server request properties."},{"name":"$modelName","type":"string|null","default":"null","optional":true,"description":"Scope from which to get data."}],"return":{"type":"bool","description":"`true` if the model is successfully populated with some data, `false` otherwise."},"abstract":true},"setValue":{"signature":"abstract public function setValue(string $property, mixed $value): void","summary":"Sets the value for the specified property.","params":[{"name":"$property","type":"string","description":"Property name."},{"name":"$value","type":"mixed","description":"Value to set."}],"return":{"type":"void"},"abstract":true},"setValues":{"signature":"abstract public function setValues(array $data, array $except = []): void","summary":"Sets values for multiple properties.","params":[{"name":"$data","type":"array","description":"Key value pairs to set for the properties."},{"name":"$except","type":"array","default":"[]","optional":true,"description":"Properties to exclude from the setting using camelCase names. If not empty, the listed properties are skipped. If empty, all properties from `$data` are applied."}],"return":{"type":"void"},"abstract":true},"toArray":{"signature":"abstract public function toArray(bool $snakeCase = false, array $exceptProperties = []): array<string, mixed>","summary":"Returns model properties as an array.","params":[{"name":"$snakeCase","type":"bool","default":"false","optional":true,"description":"Whether keys should be converted to snake_case."},{"name":"$exceptProperties","type":"array","default":"[]","optional":true,"description":"List of properties to exclude."}],"return":{"type":"array<string, mixed>"},"abstract":true}}},"UIAwesome\\Model\\TypeCollector":{"kind":"class","modifiers":["final"],"url":"https://yii2-framework.github.io/docs/extensions/model/reference/typecollector/","summary":"Collects and manages model property types and values.","methods":{"__construct":{"signature":"public function __construct(UIAwesome\\Model\\ModelInterface $model)","summary":"Collects property metadata for the supplied model.","params":[{"name":"$model","type":"UIAwesome\\Model\\ModelInterface","description":"Model whose properties are collected and assigned."}]},"add":{"signature":"public function add(string $property, array|string $type): void","summary":"Adds a new property to the list of properties types.","params":[{"name":"$property","type":"string","description":"Name of the property."},{"name":"$type","type":"array|string","description":"Type of the property."}],"return":{"type":"void"}},"getTypes":{"signature":"public function getTypes(): array","summary":"Returns the list of properties types indexed by property name.","return":{"type":"array","description":"List of properties types indexed by property name."}},"getValue":{"signature":"public function getValue(string $property): mixed","summary":"Returns the value of a property.","params":[{"name":"$property","type":"string","description":"Property name."}],"return":{"type":"mixed","description":"Value of the property."}},"has":{"signature":"public function has(string $property): bool","summary":"Checks whether a property exists.","params":[{"name":"$property","type":"string","description":"Property name."}],"return":{"type":"bool","description":"`true` if the property exists, `false` otherwise."}},"isForModel":{"signature":"public function isForModel(UIAwesome\\Model\\ModelInterface $model): bool","summary":"Checks whether this collector is bound to the exact model instance.","params":[{"name":"$model","type":"UIAwesome\\Model\\ModelInterface"}],"return":{"type":"bool"}},"isType":{"signature":"public function isType(string $property, string $type): bool","summary":"Checks whether a property supports the specified type.","params":[{"name":"$property","type":"string","description":"Property name."},{"name":"$type","type":"string","description":"Type name."}],"return":{"type":"bool","description":"`true` if the property supports the specified type, `false` otherwise."}},"phpTypeCast":{"signature":"public function phpTypeCast(string $property, mixed $value): mixed","summary":"Converts the value of an property to the type specified by type hinting in the PHPDoc.","params":[{"name":"$property","type":"string","description":"Property name."},{"name":"$value","type":"mixed","description":"Value to be converted."}],"return":{"type":"mixed","description":"Value of the property converted to the type specified by PHPDoc."}},"setValue":{"signature":"public function setValue(string $property, mixed $value): void","summary":"Sets a value for one property.","params":[{"name":"$property","type":"string","description":"The property name."},{"name":"$value","type":"mixed","description":"The value to assign."}],"return":{"type":"void"}},"setValues":{"signature":"public function setValues(array $data, array $except = []): void","summary":"Sets values for multiple properties at once.","params":[{"name":"$data","type":"array"},{"name":"$except","type":"array","default":"[]","optional":true}],"return":{"type":"void"}},"toArray":{"signature":"public function toArray(bool $snakeCase, array $exceptProperties = []): array","summary":"Returns an array representation of the model properties and their values.","params":[{"name":"$snakeCase","type":"bool","description":"Whether to convert property names to snake_case."},{"name":"$exceptProperties","type":"array","default":"[]","optional":true,"description":"CamelCase property names to exclude from the resulting array."}],"return":{"type":"array","description":"An array representation of the model properties and their values."}},"withModel":{"signature":"public function withModel(UIAwesome\\Model\\ModelInterface $model): self","summary":"Copies collector state for the same model class without collecting metadata or assigning values again.","params":[{"name":"$model","type":"UIAwesome\\Model\\ModelInterface"}],"return":{"type":"self"},"throws":[{"type":"InvalidArgumentException","description":"if the target model has a different concrete class."}]}}}}}
