Completed
Pull Request — refacto/local-factory (#166)
by Nuno
19:50 queued 15:15
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
class attributeForFaceting implements SettingContract
20
{
21
    /**
22
     * @var string[]
23
     */
24
    private static $attributesForFacetingKeys = [
25
        '*category*',
26
        '*list*',
27
        '*country*',
28
        '*city*',
29
        '*type*',
30
    ];
31
32
    /**
33
     * Checks if the given key/value is a 'attributesForFaceting'.
34
     *
35
     * @param  string $key
36
     * @param  array|null|string $value
37
     * @param  array $attributesForFaceting
38
     *
39
     * @return array
40
     */
41 3
    public function getValue(string $key, $value, array $attributesForFaceting): array
42
    {
43 3
        if (Str::is(self::$attributesForFacetingKeys, $key)) {
44 3
            $attributesForFaceting[] = $key;
45
        }
46
47 3
        return $attributesForFaceting;
48
    }
49
}
50