1<?php
2
3namespace Elastica\QueryBuilder;
4
5/**
6 * Abstract Version class.
7 *
8 * @author Manuel Andreo Garcia <andreo.garcia@googlemail.com>
9 */
10abstract class Version
11{
12    /**
13     * supported query methods.
14     *
15     * @var string[]
16     */
17    protected $queries = [];
18
19    /**
20     * supported filter methods.
21     *
22     * @var string[]
23     */
24    protected $filters = [];
25
26    /**
27     * supported aggregation methods.
28     *
29     * @var string[]
30     */
31    protected $aggregations = [];
32
33    /**
34     * supported $suggester methods.
35     *
36     * @var string[]
37     */
38    protected $suggesters = [];
39
40    /**
41     * returns true if $name is supported, false otherwise.
42     *
43     * @param string $name
44     * @param string $type
45     *
46     * @return bool
47     */
48    public function supports(string $name, string $type): bool
49    {
50        switch ($type) {
51            case DSL::TYPE_QUERY:
52                return \in_array($name, $this->queries, true);
53            case DSL::TYPE_AGGREGATION:
54                return \in_array($name, $this->aggregations, true);
55            case DSL::TYPE_SUGGEST:
56                return \in_array($name, $this->suggesters, true);
57        }
58
59        // disables version check in Facade for custom DSL objects
60        return true;
61    }
62
63    /**
64     * @return string[]
65     */
66    public function getAggregations(): array
67    {
68        return $this->aggregations;
69    }
70
71    /**
72     * @return string[]
73     */
74    public function getQueries(): array
75    {
76        return $this->queries;
77    }
78
79    /**
80     * @return string[]
81     */
82    public function getSuggesters(): array
83    {
84        return $this->suggesters;
85    }
86}
87