<?php

namespace App\Transformer\Anime;

class AnimeTransformer
{

    public function newBuildChatList($data): array
    {
        return [
            'meta'      => getMeta($data),
            // 'header'    => $data['header'],
            'list'      => $this->newEachChatList($data),
        ];
    }

    private function newEachChatList($list): array
    {
        $result = [];
        if (empty($list)) return $result;

        foreach ($list as $item) {
            $result[] = [
                'anime_id'          => getProp($item, 'id'),
                'anime_name'        => '《'.getProp($item, 'anime_name').'》',
                'first_frame_url'   => getProp($item, 'first_frame_url'),
                'is_multi'          => getProp($item, 'is_multi'),
                'created_at'        => transDate(getProp($item, 'created_at')),
            ];
        }

        return $result;
    }
}
