ThriftTransportRequest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 5
c 1
b 1
f 0
lcom 0
cbo 2
dl 0
loc 60
ccs 15
cts 15
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setBody() 0 4 1
A setPath() 0 4 1
A getWrappedRequest() 0 4 1
A setQueryParams() 0 4 1
A __construct() 0 5 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
namespace Elastification\Client\Transport\Thrift;
19
20
use Elasticsearch\Method;
21
use Elasticsearch\RestRequest;
22
use Elastification\Client\Transport\TransportRequestInterface;
23
24
/**
25
 * @package Elastification\Client\Transport\Thrift
26
 * @author  Mario Mueller
27
 */
28
class ThriftTransportRequest implements TransportRequestInterface
29
{
30
    /**
31
     * @var RestRequest
32
     */
33
    private $request;
34
35
    /**
36
     * @param string $method The http method to use.
37
     * @param array  $vals
38
     */
39 2
    function __construct($method, $vals = null)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
40
    {
41 2
        $this->request = new RestRequest($vals);
42 2
        $this->request->method = array_flip(Method::$__names)[$method];
43 2
    }
44
45
    /**
46
     * @param string $body The raw request body.
47
     *
48
     * @return void
49
     * @author Mario Mueller
50
     */
51 1
    public function setBody($body)
52
    {
53 1
        $this->request->body = $body;
54 1
    }
55
56
    /**
57
     * @param string $path The path according to the Elasticsearch http interface.
58
     *
59
     * @return void
60
     * @author Mario Mueller
61
     */
62 1
    public function setPath($path)
63
    {
64 1
        $this->request->uri = $path;
65 1
    }
66
67
    /**
68
     * @return RestRequest
69
     * @author Mario Mueller
70
     */
71 1
    public function getWrappedRequest()
72
    {
73 1
        return $this->request;
74
    }
75
76
    /**
77
     * @param array $params
78
     *
79
     * @return void
80
     * @author Mario Mueller
81
     */
82 1
    public function setQueryParams(array $params)
83
    {
84 1
        $this->request->parameters = $params;
85 1
    }
86
87
}
88