Skip to content
Snippets Groups Projects
DeleteIndex.php 498 B
Newer Older
Pavel's avatar
Pavel committed
<?php

namespace IQDEV\ElasticSearch\Indexer;

final class DeleteIndex implements Index
{
    private string $name;
    private ?string $id;

    public function __construct(
        string  $name,
        ?string $id = null
    )
    {
        $this->name = $name;
        $this->id = $id;
    }

    public function es(): array
    {
        $es = [
            'index' => $this->name
        ];

        if ($this->id) {
            $es['id'] = $this->id;
        }

        return $es;
    }
}