<?php

namespace ZenoChatbot\Services\Indexing;

use ZenoChatbot\Services\Indexing\Contracts\IndexStrategyInterface;
use ZenoChatbot\Services\Indexing\Contracts\JobStrategyInterface;

class ContentIndexService
{
    /** @var string */
    private $basePath;

    private function __construct(string $basePath)
    {
        $this->basePath = $basePath;
    }

    /** @return self */
    public static function create(string $basePath): self
    {
        return new static($basePath);
    }

    /** @return array<string,mixed> */
    public function index(IndexStrategyInterface $strategy): array
    {
        return $strategy->index();
    }

    /** @return array<string,mixed> */
    public function get(IndexStrategyInterface $strategy): array
    {
        return $strategy->get();
    }

    /** @return array<string,mixed> */
    public function clear(IndexStrategyInterface $strategy): array
    {
        return $strategy->clear();
    }

    /** @return array<string,mixed> */
    public function stats(IndexStrategyInterface $strategy): array
    {
        return $strategy->stats();
    }

    /** @return array<string,mixed> */
    public function startJob(JobStrategyInterface $strategy): array
    {
        return $strategy->startJob();
    }

    /** @return array<string,mixed> */
    public function processJob(JobStrategyInterface $strategy, string $jobId): array
    {
        return $strategy->processJob($jobId);
    }

    /** @return array<string,mixed> */
    public function jobStatus(JobStrategyInterface $strategy, string $jobId): array
    {
        return $strategy->getJobStatus($jobId);
    }

    /** @return array<string,mixed> */
    public function sync(JobStrategyInterface $strategy): array
    {
        return $strategy->sync();
    }

    public function basePath(): string
    {
        return $this->basePath;
    }
}
