Added VKBot
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Library\VK\Mapper\Strategy;
|
||||
|
||||
use App\Library\VK\Entity\VkPost;
|
||||
use App\Library\VK\Mapper\AttachmentMapper;
|
||||
use App\Library\VK\Mapper\Strategy\Interfaces\MappingStrategyInterface;
|
||||
|
||||
class SimplePostStrategy implements MappingStrategyInterface
|
||||
{
|
||||
public function __construct(private AttachmentMapper $attachmentMapper) {}
|
||||
|
||||
public function map(array $item): VkPost
|
||||
{
|
||||
$post = new VkPost();
|
||||
$post->setId($item['id']);
|
||||
$post->setOwnerId($item['owner_id']);
|
||||
$post->setAuthorId($item['from_id']);
|
||||
$post->setDate($item['date']);
|
||||
$post->setIsPost();
|
||||
$post->setText($item['text'] ?? '');
|
||||
|
||||
if (! empty($item['attachments'])) {
|
||||
$attachments = $this->attachmentMapper->map($item['attachments']);
|
||||
$post->setAttachments($attachments);
|
||||
}
|
||||
|
||||
return $post;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user