type-lang / mapper
Library for mapping variable types to other types
dev-master / 1.0.x-dev
2024-07-03 19:15 UTC
Requires
- php: ^8.1
- psr/simple-cache: ^1.0|^2.0|^3.0
- type-lang/parser: ^1.0
- type-lang/printer: ^1.0
- type-lang/reader: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.53
- jetbrains/phpstorm-attributes: ^1.0
- phplrt/compiler: ^3.6
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^1.11
- phpstan/phpstan-strict-rules: ^1.6
- phpunit/phpunit: ^10.5|^11.0
- rector/rector: ^1.1
- symfony/cache: ^5.4|^6.0|^7.0
This package is auto-updated.
Last update: 2024-07-03 19:16:03 UTC
README
![](https://github.com/php-type-language/.github/raw/master/assets/dark.png?raw=true)
The best PHP mapper you've ever seen =)
- You can see some examples here
- Full documentation in progress...
Installation
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
Quick Start
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" // }