Final Class Yiisoft\Hydrator\ArrayData
| Inheritance | Yiisoft\Hydrator\ArrayData |
|---|---|
| Implements | Yiisoft\Hydrator\DataInterface |
Holds data to hydrate an object from and a map to use when populating an object.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Hydrator\ArrayData | |
| getValue() | Yiisoft\Hydrator\ArrayData |
Method Details
| public mixed __construct ( array $data = [], array|Yiisoft\Hydrator\ObjectMap $map = [], boolean $strict = false ) | ||
| $data | array |
Data to hydrate object from. |
| $map | array|Yiisoft\Hydrator\ObjectMap |
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\Hydrator\Result getValue ( string $name ) | ||
| $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);
}
Signup or Login in order to comment.