The best PHP mapper you've ever seen =)
- You can see some examples here
- Full documentation in progress...
Mapper package is available as Composer repository and can be installed using the following command in a root of your project:
composer require type-lang/mapper
class ExampleObject
{
public function __construct(
public readonly string $name,
) {}
}
$mapper = new \TypeLang\Mapper\Mapper();
$normalized = $mapper->normalize(new ExampleObject('Example'));
// Expected Result:
// array:1 [
// "name" => "Example"
// ]
$denormalized = $mapper->denormalize($normalized, ExampleObject::class);
// Expected Result:
// ExampleObject {#14
// +name: "Example"
// }