Completed
Pull Request — master (#164)
by
unknown
04:23
created

DisableTypoToleranceAttribute   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 60%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 32
ccs 3
cts 5
cp 0.6
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A exist() 0 9 3
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 DisableTypoToleranceAttribute implements SettingContract
20
{
21
    /**
22
     * @var string[]
23
     */
24
    private static $disableTypoToleranceOnAttributesKeys = [
25
        'slug',
26
        '*_slug',
27
        'slug_*',
28
        '*code*',
29
        '*sku*',
30
        '*reference*',
31
    ];
32
33
    /**
34
     * Checks if the given key/value is a 'disableTypoToleranceOnAttributes'.
35
     *
36
     * @param  string $key
37
     * @param  mixed $value
38
     * @param array $disableTypoToleranceOnAttributes
39
     *
40
     * @return array
41
     */
42 3
    public static function exist(string $key, $value, array $disableTypoToleranceOnAttributes): array
43
    {
44 3
        if (is_string($key) && Str::is(self::$disableTypoToleranceOnAttributesKeys, $key)) {
45
            $disableTypoToleranceOnAttributes[] = $key;
46
47
            return $disableTypoToleranceOnAttributes;
48
        }
49
50 3
        return $disableTypoToleranceOnAttributes;
51
    }
52
}
53