<?php

namespace FSPoster\App\Watermark\App\DTOs\Response;

class WatermarkUsageResult
{
    public bool $success = false;
    public ?string $errorMessage = null;
    public int $image = 0;
    public int $video = 0;

    public static function success(int $image, int $video): self
    {
        $dto = new self();
        $dto->success = true;
        $dto->image = $image;
        $dto->video = $video;

        return $dto;
    }

    public static function failure(string $errorMessage): self
    {
        $dto = new self();
        $dto->success = false;
        $dto->errorMessage = $errorMessage;

        return $dto;
    }

    public function countForType(string $mediaType): int
    {
        return property_exists($this, $mediaType) ? (int) $this->{$mediaType} : 0;
    }

    public function incrementForType(string $mediaType): void
    {
        if (property_exists($this, $mediaType)) {
            $this->{$mediaType}++;
        }
    }
}
