FragmentSearchFilter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 9
dl 0
loc 32
ccs 8
cts 8
cp 1
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A toArray() 0 6 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
}