summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/lib/Elastica/Filter/Type.php
blob: f9c1781349268760093e2f8399582c5b264b08e8 (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
<?php
namespace Elastica\Filter;

/**
 * Type Filter.
 *
 * @author James Wilson <jwilson556@gmail.com>
 *
 * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-type-filter.html
 */
class Type extends AbstractFilter
{
    /**
     * Type name.
     *
     * @var string
     */
    protected $_type = null;

    /**
     * Construct Type Filter.
     *
     * @param string $type Type name
     */
    public function __construct($type = null)
    {
        if ($type) {
            $this->setType($type);
        }
    }

    /**
     * Ads a field with arguments to the range query.
     *
     * @param string $typeName Type name
     *
     * @return $this
     */
    public function setType($typeName)
    {
        $this->_type = $typeName;

        return $this;
    }

    /**
     * Convert object to array.
     *
     * @see \Elastica\Filter\AbstractFilter::toArray()
     *
     * @return array Filter array
     */
    public function toArray()
    {
        return array(
            'type' => array('value' => $this->_type),
        );
    }
}