1<?php
2
3declare(strict_types = 1);
4
5namespace Elasticsearch\Endpoints\Cat;
6
7use Elasticsearch\Endpoints\AbstractEndpoint;
8
9/**
10 * Class Fielddata
11 *
12 * @category Elasticsearch
13 * @package  Elasticsearch\Endpoints\Cat
14 * @author   Zachary Tong <zach@elastic.co>
15 * @license  http://www.apache.org/licenses/LICENSE-2.0 Apache2
16 * @link     http://elastic.co
17 */
18class Fielddata extends AbstractEndpoint
19{
20    private $fields;
21
22    public function setFields(?string $fields): Fielddata
23    {
24        if (isset($fields) !== true) {
25            return $this;
26        }
27
28        $this->fields = $fields;
29
30        return $this;
31    }
32
33    public function getURI(): string
34    {
35        $fields = $this->fields ?? null;
36
37        if (isset($fields)) {
38            return "/_cat/fielddata/$fields";
39        }
40
41        return "/_cat/fielddata";
42    }
43
44    public function getParamWhitelist(): array
45    {
46        return [
47            'format',
48            'bytes',
49            'local',
50            'master_timeout',
51            'h',
52            'help',
53            's',
54            'v',
55            'fields'
56        ];
57    }
58
59    public function getMethod(): string
60    {
61        return 'GET';
62    }
63}
64