Ids   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 56
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A compile() 0 11 2
A __construct() 0 4 1
A name() 0 3 1
A type() 0 5 1
1
<?php
2
/*
3
 * This file is part of PHPinnacle/Elastics.
4
 *
5
 * (c) PHPinnacle Team <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
declare(strict_types=1);
12
13
namespace PHPinnacle\Elastics\Query;
14
15
use PHPinnacle\Elastics\Query;
16
17
class Ids implements Query
18
{
19
    /**
20
     * @var array
21
     */
22
    private $values;
23
24
    /**
25
     * @var array
26
     */
27
    private $types;
28
29
    /**
30
     * @param array       $values
31
     * @param string[] ...$types
32
     */
33 3
    public function __construct(array $values, string ...$types)
34
    {
35 3
        $this->values = $values;
36 3
        $this->types  = $types;
37 3
    }
38
39
    /**
40
     * @param string[] ...$types
41
     *
42
     * @return self
43
     */
44 1
    public function type(string ...$types): self
45
    {
46 1
        $this->types = $types;
47
48 1
        return $this;
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54 1
    public function name(): string
55
    {
56 1
        return 'ids';
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62 2
    public function compile(): array
63
    {
64
        $query = [
65 2
            'values' => $this->values,
66
        ];
67
68 2
        if (count($this->types) !== 0) {
69 1
            $query['type'] = $this->types;
70
        }
71
72 2
        return $query;
73
    }
74
}
75