<?php

declare(strict_types=1);

namespace PhpWA\Media;

use InvalidArgumentException;

final class MediaDownloadProgress
{
    /** @var int */ private $downloadedBytes;
    /** @var int */ private $totalBytes;

    public function __construct(int $downloadedBytes, int $totalBytes)
    {
        if ($totalBytes < 1 || $downloadedBytes < 0 || $downloadedBytes > $totalBytes) {
            throw new InvalidArgumentException('Media download progress is invalid.');
        }
        $this->downloadedBytes = $downloadedBytes; $this->totalBytes = $totalBytes;
    }
    public function downloadedBytes(): int { return $this->downloadedBytes; }
    public function totalBytes(): int { return $this->totalBytes; }
    public function isComplete(): bool { return $this->downloadedBytes === $this->totalBytes; }
}
