<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
anteris-dev / data-transfer-object-factory example snippets
use Anteris\DataTransferObjectFactory\Factory;
// Creates one DTO
Factory::new(PersonData::class)->make();
// Creates two DTOs in an array
Factory::new(PersonData::class)->count(2)->make();
// Sets the first name of every person to "Jim"
Factory::new(PersonData::class)
->random()
->state([
'firstName' => 'Jim',
])
->make();
// Also sets the first name of every person to "Jim"
Factory::dto(PersonData::class)
->random()
->make([
'firstName' => 'Jim',
]);
// Alternates the names of each person between "Jim" and "Susie"
Factory::dto(PersonData::class)
->random()
->sequence(
[ 'firstName' => 'Jim' ],
[ 'firstName' => 'Susie' ]
)
->make();
use Anteris\DataTransferObjectFactory\Factory;
Factory::registerAdapter(new MyCustomAdapter);
use Anteris\DataTransferObjectFactory\PropertyFactory;
use Anteris\FakerMap\FakerMap;
PropertyFactory::registerProvider('Carbon\Carbon', fn(FakerMap $fakerMap) => Carbon::parse(
$fakerMap->closest('dateTime')->fake()
));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.