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

1.0.1 2025-08-10 20:09 UTC

This package is auto-updated.

Last update: 2026-01-10 21:26:50 UTC


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;