From ce165a4e2f65e15000904d8fe54eb3169ec6e7ba Mon Sep 17 00:00:00 2001 From: Sipachev Igor Date: Mon, 9 Aug 2021 12:46:44 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BE=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Readme.md | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index e0e5ef1..5aacdf5 100644 --- a/Readme.md +++ b/Readme.md @@ -2,5 +2,79 @@ [![coverage report](https://git.rinsvent.ru/rinsvent/data2dto/badges/master/coverage.svg)](https://git.rinsvent.ru/rinsvent/data2dto/-/commits/master) Data2dto -= +=== + +## Установка +```php +composer require rinsvent-data2dto +``` + +## Пример + +### Описания ДТО +```php +class BuyRequest +{ + public string $phrase; + public int $length; + public bool $isFirst; +} + +interface BarInterface +{ + +} + +class Bar implements BarInterface +{ + public float $barField; +} + +class HelloRequest +{ + #[Trim] + public string $surname; + #[PropertyPath('fake_age')] + public int $age; + public array $emails; + #[DTOMeta(class: Author::class)] + public array $authors; + public BuyRequest $buy; + #[DTOMeta(class: Bar::class)] + public BarInterface $bar; +} +``` +### Использование +```php +use Rinsvent\Data2DTO\Data2DtoConverter; + +$data2DtoConverter = new Data2DtoConverter(); + $dto = $data2DtoConverter->convert([ + 'surname' => ' asdf', + 'fake_age' => 3, + 'emails' => [ + 'sfdgsa', + 'af234f', + 'asdf33333' + ], + 'authors' => [ + [ + 'name' => 'Tolkien', + ], + [ + 'name' => 'Sapkovsky' + ] + ], + 'buy' => [ + 'phrase' => 'Buy buy!!!', + 'length' => 10, + 'isFirst' => true, + 'extraData2' => '1234' + ], + 'bar' => [ + 'barField' => 32 + ], + 'extraData1' => 'qwer' + ], HelloRequest::class); +```