Completed
Push — master ( 6bc3b4...34ca55 )
by Ralf
15s queued 11s
created

TermVectors   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 31
dl 0
loc 76
rs 10
c 0
b 0
f 0
wmc 8
1
<?php
2
/**
3
 * User: zach
4
 * Date: 05/31/2013
5
 * Time: 16:47:11 pm
6
 */
7
8
namespace Elasticsearch\Endpoints;
9
10
use Elasticsearch\Endpoints\AbstractEndpoint;
11
use Elasticsearch\Common\Exceptions;
12
13
/**
14
 * Class TermVector
15
 * @package Elasticsearch\Endpoints
16
 */
17
class TermVectors extends AbstractEndpoint
18
{
19
20
    /**
21
     * @param array $body
22
     *
23
     * @throws \Elasticsearch\Common\Exceptions\InvalidArgumentException
24
     * @return $this
25
     */
26
    public function setBody($body)
27
    {
28
        if (isset($body) !== true) {
29
            return $this;
30
        }
31
32
        $this->body = $body;
33
        return $this;
34
    }
35
36
37
    /**
38
     * @throws \Elasticsearch\Common\Exceptions\RuntimeException
39
     * @return string
40
     */
41
    protected function getURI()
42
    {
43
        if (isset($this->index) !== true) {
44
            throw new Exceptions\RuntimeException(
45
                'index is required for TermVectors'
46
            );
47
        }
48
        if (isset($this->type) !== true) {
49
            throw new Exceptions\RuntimeException(
50
                'type is required for TermVectors'
51
            );
52
        }
53
        if (isset($this->id) !== true) {
54
            throw new Exceptions\RuntimeException(
55
                'id is required for TermVectors'
56
            );
57
        }
58
59
        $index = $this->index;
60
        $type  = $this->type;
61
        $id    = $this->id;
62
        $uri   = "/$index/$type/$id/_termvectors";
63
64
        return $uri;
65
66
    }
67
68
    /**
69
     * @return string[]
70
     */
71
    protected function getParamWhitelist()
72
    {
73
        return array(
74
            'term_statistics',
75
            'field_statistics',
76
            'fields',
77
            'offsets',
78
            'positions',
79
            'payloads',
80
            'preference',
81
            'routing',
82
            'parent',
83
            'realtime'
84
        );
85
    }
86
87
    /**
88
     * @return string
89
     */
90
    protected function getMethod()
91
    {
92
        return 'POST';
93
    }
94
}