Final Class Yiisoft\Hydrator\ArrayData
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Yiisoft\ |
Holds data to hydrate an object from and a map to use when populating an object.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
|
| getValue() | Yiisoft\ |
Method Details
| public mixed __construct ( array $data = [], array|Yiisoft\ | ||
| $data | array |
Data to hydrate object from. |
| $map | array|Yiisoft\ |
Object property names mapped to keys in the data array that hydrator will use when hydrating an object. |
| $strict | boolean |
Whether to hydrate properties from the map only. |
public function __construct(
private readonly array $data = [],
array|ObjectMap $map = [],
private readonly bool $strict = false,
) {
$this->objectMap = is_array($map) ? new ObjectMap($map) : $map;
}
| public Yiisoft\ | ||
| $name | string | |
public function getValue(string $name): Result
{
if ($this->strict && !$this->objectMap->exists($name)) {
return Result::fail();
}
$path = $this->objectMap->getPath($name) ?? $name;
if ($path instanceof ObjectMap) {
return $this->getValueByObjectMap($this->data, $path);
}
return $this->getValueByPath($this->data, $path);
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.