first commit

This commit is contained in:
Alex
2025-07-06 18:52:32 +03:00
commit bcd8a52d06
27 changed files with 1126 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace BushlanovDev\MaxMessengerBot;
use BushlanovDev\MaxMessengerBot\Models\BotCommand;
use BushlanovDev\MaxMessengerBot\Models\BotInfo;
/**
* Creates DTOs from raw associative arrays returned by the API client.
*/
class ModelFactory
{
/**
* @param array<string, mixed> $data
*
* @return BotInfo
*/
public function createBotInfo(array $data): BotInfo
{
$data['commands'] = isset($data['commands']) && is_array($data['commands'])
? array_map([BotCommand::class, 'fromArray'], $data['commands']) : null;
return BotInfo::fromArray($data);
}
}