Data mapper is a PHP package to map any unstructured data to a class or native type.
It can handle arrays, collections, recursive properties and virtual properties without breaking a sweat. The package was built to be simple, light weight and as fast as possible!
class User {
public string $name;
public string $email;
public UserAddress $address;
}
$mapper = new Mapper();
$user = $mapper->map(User::class, [
'name' => 'Jerodev',
'email' => '[email protected]',
'address' => [
'street' => 'FooLane',
'number' => 42,
'city' => 'SomeWhere',
],
]);
For example, this can make it verry easy to map data coming from an api. All you have to do is set up the classes and provide the data, the mapper will take care of the rest.