Поправил описание
This commit is contained in:
parent
7f5e04539a
commit
cc98dddedf
99
Readme.md
99
Readme.md
@ -30,17 +30,18 @@ class Bar implements BarInterface
|
|||||||
public float $barField;
|
public float $barField;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[HelloSchema]
|
||||||
class HelloRequest
|
class HelloRequest
|
||||||
{
|
{
|
||||||
#[Trim]
|
#[Trim]
|
||||||
public string $surname;
|
public string $surname;
|
||||||
#[PropertyPath('fake_age')]
|
#[DataPath('fake_age')]
|
||||||
public int $age;
|
public int $age;
|
||||||
public array $emails;
|
public array $emails;
|
||||||
#[DTOMeta(class: Author::class)]
|
|
||||||
public array $authors;
|
public array $authors;
|
||||||
|
public array $authors2;
|
||||||
|
public array $authors3;
|
||||||
public BuyRequest $buy;
|
public BuyRequest $buy;
|
||||||
#[DTOMeta(class: Bar::class)]
|
|
||||||
public BarInterface $bar;
|
public BarInterface $bar;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -48,33 +49,85 @@ class HelloRequest
|
|||||||
```php
|
```php
|
||||||
use Rinsvent\DTO2Data\Dto2DataConverter;
|
use Rinsvent\DTO2Data\Dto2DataConverter;
|
||||||
|
|
||||||
$dto2DataConverter = new Dto2DataConverter();
|
$helloRequest = new HelloRequest;
|
||||||
$dto = $dto2DataConverter->convert([
|
$helloRequest->surname = ' asdf';
|
||||||
'surname' => ' asdf',
|
$helloRequest->age = 3;
|
||||||
'fake_age' => 3,
|
$helloRequest->emails =[
|
||||||
'emails' => [
|
'sfdgsa',
|
||||||
'sfdgsa',
|
'af234f',
|
||||||
'af234f',
|
'asdf33333'
|
||||||
'asdf33333'
|
];
|
||||||
|
$author1 = new Author();
|
||||||
|
$author1->name = 'Tolkien';
|
||||||
|
$author2 = new Author();
|
||||||
|
$author2->name = 'Sapkovsky';
|
||||||
|
$helloRequest->authors = [
|
||||||
|
$author1,
|
||||||
|
$author2
|
||||||
|
];
|
||||||
|
$helloRequest->authors2 = [
|
||||||
|
[
|
||||||
|
"name" => "Tolkien"
|
||||||
],
|
],
|
||||||
'authors' => [
|
[
|
||||||
|
"name" => "Sapkovsky"
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$helloRequest->authors3 = [
|
||||||
|
[
|
||||||
|
"name" => "Tolkien"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"name" => "Sapkovsky"
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$buy = new BuyRequest();
|
||||||
|
$buy->phrase = 'Buy buy!!!';
|
||||||
|
$buy->length = 10;
|
||||||
|
$buy->isFirst = true;
|
||||||
|
$helloRequest->buy = $buy;
|
||||||
|
$bar = new Bar();
|
||||||
|
$bar->barField = 32;
|
||||||
|
$helloRequest->bar = $bar;
|
||||||
|
|
||||||
|
$dto2DataConverter = new Dto2DataConverter();
|
||||||
|
$dto = $dto2DataConverter->convert($helloRequest);
|
||||||
|
```
|
||||||
|
### Результат
|
||||||
|
```php
|
||||||
|
$dto = [
|
||||||
|
"surname" => "asdf",
|
||||||
|
"fake_age" => 3,
|
||||||
|
"emails" => [
|
||||||
|
"sfdgsa",
|
||||||
|
"af234f",
|
||||||
|
"asdf33333"
|
||||||
|
],
|
||||||
|
"authors" => [
|
||||||
[
|
[
|
||||||
'name' => 'Tolkien',
|
"name" => "Tolkien"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'Sapkovsky'
|
"name" => "Sapkovsky"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'buy' => [
|
"authors2" => [
|
||||||
'phrase' => 'Buy buy!!!',
|
[
|
||||||
'length' => 10,
|
"name" => "Tolkien"
|
||||||
'isFirst' => true,
|
],
|
||||||
'extraData2' => '1234'
|
[
|
||||||
|
"name" => "Sapkovsky"
|
||||||
|
]
|
||||||
],
|
],
|
||||||
'bar' => [
|
"authors3" => [],
|
||||||
'barField' => 32
|
"buy" => [
|
||||||
|
"phrase" => "Buy buy!!!",
|
||||||
|
"length" => 10,
|
||||||
|
"isFirst" => true
|
||||||
],
|
],
|
||||||
'extraData1' => 'qwer'
|
"bar" => [
|
||||||
], new HelloRequest);
|
"barField" => 32
|
||||||
|
]
|
||||||
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user