1. Go to this page and download the library: Download zawiszaty/auto-dto library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zawiszaty / auto-dto example snippets
class FakeObjectDTO extends ObjectDTO
{
public function __construct(object $class)
{
parent::__construct($class,FakeClass::class);
}
}
/// OR
class FakeArrayDTO extends ArrayDTO
{
public function __construct(array $params)
{
parent::__construct($params, FakeClass::class);
}
}
$dateTime = new \DateTime();
$fakeClass = new FakeClass(1, 'test', $dateTime);
$fakeDTO = new FakeObjectDTO($fakeClass);
$this->assertSame(1, $fakeDTO->id);
$this->assertSame('test', $fakeDTO->name);
$this->assertSame($dateTime, $fakeDTO->createdAt);
/// OR
$dateTime = new \DateTime();
$fakeDTO = new FakeArrayDTO([
'id' => 1,
'name' => 'test',
'createdAt' => $dateTime
]);
$this->assertSame(1, $fakeDTO->id);
$this->assertSame('test', $fakeDTO->name);
$this->assertSame($dateTime, $fakeDTO->createdAt);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.