1<?php
2
3declare(strict_types = 1);
4
5namespace Elasticsearch\Endpoints\Indices;
6
7use Elasticsearch\Endpoints\AbstractEndpoint;
8use Elasticsearch\Common\Exceptions;
9
10/**
11 * Class Analyze
12 *
13 * @category Elasticsearch
14 * @package  Elasticsearch\Endpoints\Indices
15 * @author   Zachary Tong <zach@elastic.co>
16 * @license  http://www.apache.org/licenses/LICENSE-2.0 Apache2
17 * @link     http://elastic.co
18 */
19class Analyze extends AbstractEndpoint
20{
21    public function setBody($body): Analyze
22    {
23        if (isset($body) !== true) {
24            return $this;
25        }
26
27        $this->body = $body;
28
29        return $this;
30    }
31
32    public function getURI(): string
33    {
34        $index = $this->index ?? null;
35        if (isset($index)) {
36            return "/$index/_analyze";
37        }
38        return "/_analyze";
39    }
40
41    public function getParamWhitelist(): array
42    {
43        return [
44            'index'
45        ];
46    }
47
48    public function getMethod(): string
49    {
50        return isset($this->body) ? 'POST' : 'GET';
51    }
52}
53