FragmentSearchFilter::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Level23\Druid\SearchFilters;
5
6
class FragmentSearchFilter implements SearchFilterInterface
7
{
8
    /**
9
     * @var string[]
10
     */
11
    protected array $values;
12
13
    protected bool $caseSensitive;
14
15
    /**
16
     * FragmentSearchFilter constructor.
17
     *
18
     * @param string[] $values
19
     * @param bool     $caseSensitive
20
     */
21 2
    public function __construct(array $values, bool $caseSensitive = false)
22
    {
23 2
        $this->values        = $values;
24 2
        $this->caseSensitive = $caseSensitive;
25
    }
26
27
    /**
28
     * Return the search filter so that it can be used in a search query.
29
     *
30
     * @return array<string,string|bool|string[]>
31
     */
32 2
    public function toArray(): array
33
    {
34 2
        return [
35 2
            'type'           => 'fragment',
36 2
            'values'         => $this->values,
37 2
            'case_sensitive' => $this->caseSensitive,
38 2
        ];
39
    }
40
}