<?php

declare(strict_types=1);

namespace App\Library\VK\Mapper;

class AttachmentMapper
{
    public function map(array $attachments = []): array
    {
        $photos = [];
        foreach ($attachments as $attachment) {
            if( ($attachment['type'] === 'photo') && $attachment['photo']['sizes'] ) {
                $photos[] = end($attachment['photo']['sizes'])['url'];
            }
        }

        return $photos;
    }
}
