lokus / dto
Package for creating DTOs
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/lokus/dto
Requires
- php: >=8.3
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^12
- symfony/var-dumper: ^7.3
README
This package allows you to create DTO from array with providing validation of key names and parameteres of constructor, also validate types of array values.
Installation:
composer require lokus/dto
Example of usage:
use Lokus\Dto\SimpleDTO; final readonly class PostDTO extends SimpleDTO { public function __construct( public string $title, public string $content, ) {} } $data = [ 'title' => 'Simple Title', 'content' => 'Simple Content', ]; $dto = PostDTO::fromArray($data); echo $dto->title; echo $dto->content;