<?php

namespace ZenoChatbot\Services\Indexing\Strategies;

use ZenoChatbot\Services\Indexing\Contracts\IndexStrategyInterface;
use ZenoChatbot\Services\Indexing\Engine\InternalContentIndexEngine;

class InternalContentIndex implements IndexStrategyInterface
{
    /** @var array<int,string> */
    private $postTypes;

    /** @param array<int,string> $postTypes */
    public function __construct(array $postTypes = [])
    {
        $this->postTypes = $postTypes;
    }

    public function key(): string
    {
        return 'internal';
    }

    public function index(): array
    {
        return InternalContentIndexEngine::buildIndex($this->postTypes);
    }

    public function get(): array
    {
        return [
            'success' => true,
            'data' => InternalContentIndexEngine::getAll(),
        ];
    }

    public function clear(): array
    {
        return InternalContentIndexEngine::clearIndex();
    }

    public function stats(): array
    {
        return InternalContentIndexEngine::getStats();
    }
}
