<?php

namespace App\Domain\Scraping\Application\Response;

readonly class TestScraperConfigurationResponse
{
    public function __construct(
        public bool $success,
        public array $imageUrls,
        public int $totalImages,
        public string $testedUrl,
        public string $scrapingType,
        public array $errors = [],
    ) {
    }

    public static function success(array $imageUrls, string $testedUrl, string $scrapingType): self
    {
        return new self(
            success: true,
            imageUrls: $imageUrls,
            totalImages: count($imageUrls),
            testedUrl: $testedUrl,
            scrapingType: $scrapingType,
            errors: []
        );
    }

    public static function failure(string $testedUrl, string $scrapingType, array $errors): self
    {
        return new self(
            success: false,
            imageUrls: [],
            totalImages: 0,
            testedUrl: $testedUrl,
            scrapingType: $scrapingType,
            errors: $errors
        );
    }
}
