<?php

namespace LaraBB\Torrent\Tasks;

use LaraBB\Torrent\Models\Torrent;

class UpdateTask
{
    /**
     * @param Torrent $torrent
     * @param array $data
     * @return bool
     */
    public function run(Torrent $torrent, array $data): bool
    {
        $torrent->leecher  = $data['leecher'] ?? $torrent->leecher;
        $torrent->seeder   = $data['seeder'] ?? $torrent->seeder;
        $torrent->finished = $data['finished'] ?? $torrent->finished;

        return $torrent->save();
    }
}
