summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version.php
blob: 5230600de005d19625a57659e0aa89a93fbd809a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
namespace Elastica\QueryBuilder;

/**
 * Abstract Version class.
 *
 * @author Manuel Andreo Garcia <andreo.garcia@googlemail.com>
 */
abstract class Version
{
    /**
     * supported query methods.
     *
     * @var string[]
     */
    protected $queries = array();

    /**
     * supported filter methods.
     *
     * @var string[]
     */
    protected $filters = array();

    /**
     * supported aggregation methods.
     *
     * @var string[]
     */
    protected $aggregations = array();

    /**
     * supported $suggester methods.
     *
     * @var string[]
     */
    protected $suggesters = array();

    /**
     * returns true if $name is supported, false otherwise.
     *
     * @param string $name
     * @param $type
     *
     * @return bool
     */
    public function supports($name, $type)
    {
        switch ($type) {
            case DSL::TYPE_QUERY:
                $supports = in_array($name, $this->queries);
                break;
            case DSL::TYPE_FILTER:
                $supports = in_array($name, $this->filters);
                break;
            case DSL::TYPE_AGGREGATION:
                $supports = in_array($name, $this->aggregations);
                break;
            case DSL::TYPE_SUGGEST:
                $supports = in_array($name, $this->suggesters);
                break;
            default:
                // disables version check in Facade for custom DSL objects
                $supports = true;
        }

        return $supports;
    }

    /**
     * @return string[]
     */
    public function getAggregations()
    {
        return $this->aggregations;
    }

    /**
     * @return string[]
     */
    public function getFilters()
    {
        return $this->filters;
    }

    /**
     * @return string[]
     */
    public function getQueries()
    {
        return $this->queries;
    }

    /**
     * @return string[]
     */
    public function getSuggesters()
    {
        return $this->suggesters;
    }
}