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

namespace Elastica\Filter;

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

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

    /**
     * Ads a field with arguments to the range query
     *
     * @param  string                     $typeName Type name
     * @return \Elastica\Filter\Type current object
     */
    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)
        );
    }
}