DocumentResponse::getVersion()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 1
Metric Value
dl 6
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
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
namespace Elastification\Client\Response\V090x;
19
20
use Elastification\Client\Exception\ResponseException;
21
use Elastification\Client\Response\Response;
22
23
/**
24
 * Class DocumentResponse
25
 *
26
 * @package Elastification\Client\Response\V090x
27
 * @author  Daniel Wendlandt
28
 */
29 View Code Duplication
class DocumentResponse extends Response
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
{
31
32
    const PROP_ID = '_id';
33
    const PROP_SOURCE = '_source';
34
    const PROP_EXISTS = 'exists';
35
    const PROP_VERSION = '_version';
36
    const PROP_INDEX = '_index';
37
    const PROP_TYPE = '_type';
38
39
    /**
40
     * checks if source exists
41
     *
42
     * @return bool
43
     * @author Daniel Wendlandt
44
     */
45 5
    public function hasSource()
46
    {
47 5
        $this->processData();
48
49 5
        return $this->has(self::PROP_SOURCE);
50
    }
51
52
    /**
53
     * gets the source of the response
54
     *
55
     * @return array
56
     * @throws \Elastification\Client\Exception\ResponseException
57
     * @author Daniel Wendlandt
58
     */
59 3
    public function getSource()
60
    {
61 3
        if (!$this->hasSource()) {
62 1
            throw new ResponseException(self::PROP_SOURCE . ' is not set.');
63
        }
64
65 2
        return $this->get(self::PROP_SOURCE);
66
    }
67
68
    /**
69
     * Getter Method
70
     *
71
     * @return mixed
72
     * @author Daniel Wendlandt
73
     */
74 2
    public function exists()
75
    {
76 2
        $this->processData();
77
78 2
        return $this->get(self::PROP_EXISTS);
79
    }
80
81
    /**
82
     * Getter Method
83
     *
84
     * @return mixed
85
     * @author Daniel Wendlandt
86
     */
87 2
    public function getId()
88
    {
89 2
        $this->processData();
90
91 2
        return $this->get(self::PROP_ID);
92
    }
93
94
    /**
95
     * Getter Method
96
     *
97
     * @return mixed
98
     * @author Daniel Wendlandt
99
     */
100 2
    public function getVersion()
101
    {
102 2
        $this->processData();
103
104 2
        return $this->get(self::PROP_VERSION);
105
    }
106
107
    /**
108
     * Getter Method
109
     *
110
     * @return mixed
111
     * @author Daniel Wendlandt
112
     */
113 2
    public function getIndex()
114
    {
115 2
        $this->processData();
116
117 2
        return $this->get(self::PROP_INDEX);
118
    }
119
120
    /**
121
     * Getter Method
122
     *
123
     * @return mixed
124
     * @author Daniel Wendlandt
125
     */
126 5
    public function getType()
127
    {
128 2
        $this->processData();
129
130 2
        return $this->get(self::PROP_TYPE);
131 5
    }
132
133
}
134