<?php

declare(strict_types=1);

namespace ImovelZapAi\Publishing\Application\Data;

final readonly class FeedHealthData
{
    /**
     * @param  list<FeedHealthCheckData>  $checks
     */
    public function __construct(
        public array $checks,
    ) {}

    public function isHealthy(): bool
    {
        foreach ($this->checks as $check) {
            if (! $check->passed) {
                return false;
            }
        }

        return $this->checks !== [];
    }

    public function passedCount(): int
    {
        return count(array_filter($this->checks, fn (FeedHealthCheckData $check): bool => $check->passed));
    }
}
