mirror of
https://github.com/BushlanovDev/max-bot-api-client-php.git
synced 2026-08-21 13:52:07 +00:00
first commit
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user