hpkns / objkit
Create data objects from unstructured data
1.0.0
2024-09-12 09:11 UTC
Requires
- php: >=8.1
Requires (Dev)
- phpunit/phpunit: ^10.5
README
Create data objects from unstructured data
Installation
Simply get it from composer:
composer require hpkns/gadget
Usage
use Hpkns\Objkit\Attributes\ArrayOf; use Hpkns\Objkit\Buildable; use Hpkns\Objkit\ObjectBuilder; class Person { use Buildable; public function __construct( readonly string $name, readonly int $age, #[ArrayOf(Person)] readonly array $parents = [], ) { // } } $jedi = Person::build([ 'name' => 'Luke', 'age' => '19', 'parents' => [ [ 'name' => 'Anakin', 'age' => 41, ] ] ]);