AbstractSearchScrollRequest::getBody()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/*
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the MIT license.
17
 */
18
19
namespace Elastification\Client\Request\Shared;
20
21
use Elastification\Client\Request\RequestMethods;
22
use Elastification\Client\Serializer\JmsSerializer;
23
use Elastification\Client\Serializer\SerializerInterface;
24
25
/**
26
 * Class AbstractSearchScollRequest
27
 *
28
 * @package Elastification\Client\Request\Shared
29
 * @author  Daniel Wendlandt
30
 */
31
abstract class AbstractSearchScrollRequest extends AbstractBaseRequest
32
{
33
    const PARAM_SCROLL = 'scroll';
34
    const PARAM_SCROLL_ID = 'scroll_id';
35
    const REQUEST_ACTION = '_search/scroll';
36
37 39
    public function __construct($index, $type, SerializerInterface $serializer, array $serializerParams = array())
38
    {
39
        //overwriting index type for this request
40 39
        parent::__construct(null, null, $serializer, $serializerParams);
41 39
    }
42
43
    /**
44
     * @inheritdoc
45
     */
46 3
    public function getMethod()
47
    {
48 3
        return RequestMethods::GET;
49
    }
50
51
    /**
52
     * @inheritdoc
53
     */
54 3
    public function getAction()
55
    {
56 3
        return self::REQUEST_ACTION;
57
    }
58
59
    /**
60
     * @inheritdoc
61
     */
62 3
    public function getBody()
63
    {
64 3
        return null;
65
    }
66
67
    /**
68
     * @inheritdoc
69
     */
70 3
    public function setBody($body)
71
    {
72
        //do nothing
73 3
    }
74
75
    /**
76
     * Sets the scroll_id as query parameter for request
77
     *
78
     * @param string $scrollId
79
     * @author Daniel Wendlandt
80
     */
81 3
    public function setScrollId($scrollId)
82
    {
83 3
        $this->setParameter(self::PARAM_SCROLL_ID, $scrollId);
84 3
    }
85
86
    /**
87
     * Sets the scroll parameter as query parameter.
88
     * Parameter is in elastichsearch time unit
89
     * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#time-units
90
     *
91
     * @param $scrollTimeUnit
92
     * @author Daniel Wendlandt
93
     */
94 3
    public function setScroll($scrollTimeUnit)
95
    {
96 3
        $this->setParameter(self::PARAM_SCROLL, $scrollTimeUnit);
97 3
    }
98
99
}
100