0 follower

Final Class Yiisoft\Hydrator\ObjectMap

InheritanceYiisoft\Hydrator\ObjectMap

Provides a mapping of object property names to keys in the data array.

Public Properties

Hide inherited properties

Property Type Description Defined By
$map array Yiisoft\Hydrator\ObjectMap

Public Methods

Hide inherited methods

Method Description Defined By
__construct() Yiisoft\Hydrator\ObjectMap
exists() Checks if a given property name exists in the mapping array. Yiisoft\Hydrator\ObjectMap
getNames() Returns a list of property names for which mapping is set. Yiisoft\Hydrator\ObjectMap
getPath() Returns a path for a given property name or null if mapping dosen't exist. Yiisoft\Hydrator\ObjectMap

Property Details

Hide inherited properties

$map public property
public array $map null

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( array $map )
$map array

Object property names mapped to keys in the data array that hydrator will use when hydrating an object.

                public function __construct(
    public readonly array $map
) {
}

            
exists() public method

Checks if a given property name exists in the mapping array.

public boolean exists ( string $name )
$name string

The property name.

return boolean

Whether the property name exists in the mapping array.

                public function exists(string $name): bool
{
    return array_key_exists($name, $this->map);
}

            
getNames() public method

Returns a list of property names for which mapping is set.

public string[] getNames ( )
return string[]

List of property names.

                public function getNames(): array
{
    return array_keys($this->map);
}

            
getPath() public method

Returns a path for a given property name or null if mapping dosen't exist.

public string|array|self|null getPath ( string $name )
$name string

                public function getPath(string $name): string|array|self|null
{
    return $this->map[$name] ?? null;
}