You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Rinsvent
db0e7c0910
|
3 years ago | |
---|---|---|
bin/docker | 3 years ago | |
src | 3 years ago | |
tests | 3 years ago | |
.gitignore | 3 years ago | |
.gitlab-ci.yml | 3 years ago | |
Makefile | 3 years ago | |
Readme.md | 3 years ago | |
codeception.yml | 3 years ago | |
composer.json | 3 years ago | |
composer.lock | 3 years ago | |
docker-compose-ci.yml | 3 years ago | |
docker-compose.yml | 3 years ago |
Readme.md
Dto2data
Установка
composer require rinsvent/dto2data
Пример
Описания ДТО
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;
}
Использование
use Rinsvent\DTO2Data\Dto2DataConverter;
$dto2DataConverter = new Dto2DataConverter();
$dto = $dto2DataConverter->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'
], new HelloRequest);