PHP code example of emulgeator / array-to-class-mapper
1. Go to this page and download the library: Download emulgeator/array-to-class-mapper 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/ */
emulgeator / array-to-class-mapper example snippets
use Emul\ArrayToClassMapper\MapperFactory;
class DTO
{
private int $id;
private float $value;
public function __construct() {
// Constructor wont be called
}
}
$arrayToMap = [
'id' => '1',
'value' => '1.2'
];
$mapper = (new MapperFactory())->getMapper();
/** @var DTO $dto */
$dto = $mapper->map($arrayToMap, DTO::class);