Completed
Pull Request — master (#22)
by Sergey
14:58
created

ElasticsearchItemResponse   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 0
dl 0
loc 54
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A index() 0 4 1
A type() 0 4 1
A id() 0 4 1
A parent() 0 4 1
A score() 0 4 1
A found() 0 4 1
A created() 0 4 1
A source() 0 4 1
A innerHits() 0 4 1
1
<?php
2
3
namespace Isswp101\Persimmon\Response;
4
5
class ElasticsearchItemResponse
6
{
7
    private $response;
8
9
    public function __construct(array $response)
10
    {
11
        $this->response = $response;
12
    }
13
14
    public function index(): string
15
    {
16
        return $this->response['_index'];
17
    }
18
19
    public function type(): string
20
    {
21
        return $this->response['_type'];
22
    }
23
24
    public function id(): string
25
    {
26
        return $this->response['_id'];
27
    }
28
29
    public function parent()
30
    {
31
        return $this->response['_parent'] ?? null;
32
    }
33
34
    public function score(): int
35
    {
36
        return $this->response['_score'] ?? 0;
37
    }
38
39
    public function found(): bool
40
    {
41
        return $this->response['found'] ?? false;
42
    }
43
44
    public function created(): bool
45
    {
46
        return $this->response['created'] ?? false;
47
    }
48
49
    public function source(): array
50
    {
51
        return $this->response['_source'] ?? [];
52
    }
53
54
    public function innerHits(): array
55
    {
56
        return $this->response['inner_hits'] ?? [];
57
    }
58
}