<?php

namespace App\Modules\Shared\Validator\Domain;

class GenericDTO
{
  public static function generate($data)
  {
    $validateData = [static::class, 'validateData']();
    $params = array_map(function ($key, $value) use ($data) {
      return array_key_exists($key, $data) ? $data[$key] : null;
    }, array_keys($validateData), array_values($validateData));
    $dtoClassName = static::class;
    return new $dtoClassName(...$params);
  }
}
