Passed
Pull Request — master (#170)
by
unknown
08:08
created

attributeForFaceting   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 29
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * This file is part of Scout Extended.
7
 *
8
 * (c) Algolia Team <[email protected]>
9
 *
10
 *  For the full copyright and license information, please view the LICENSE
11
 *  file that was distributed with this source code.
12
 */
13
14
namespace Algolia\ScoutExtended\Settings\SettingAttribute;
15
16
use Illuminate\Support\Str;
17
use Algolia\ScoutExtended\Contracts\SettingContract;
18
19
/*
20
 * @internal
21
 */
22
final class attributeForFaceting implements SettingContract
23
{
24
    /**
25
     * @var string[]
26
     */
27
    private static $attributesForFacetingKeys = [
28
        '*category*',
29
        '*list*',
30
        '*country*',
31
        '*city*',
32
        '*type*',
33
    ];
34
35
    /**
36
     * Checks if the given key/value is a 'attributesForFaceting'.
37
     *
38
     * @param  string $key
39
     * @param  array|null|string $value
40
     * @param  array $attributesForFaceting
41
     *
42
     * @return array
43
     */
44 4
    public function getValue(string $key, $value, array $attributesForFaceting): array
45
    {
46 4
        if (Str::is(self::$attributesForFacetingKeys, $key)) {
47 3
            $attributesForFaceting[] = $key;
48
        }
49
50 4
        return $attributesForFaceting;
51
    }
52
}
53