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

UnretrievableAttribute   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 28
ccs 3
cts 4
cp 0.75
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 7 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
/*
20
 * @internal
21
 */
22
final class UnretrievableAttribute implements SettingContract
23
{
24
    /**
25
     * @var string[]
26
     */
27
    private static $unretrievableAttributesKeys = [
28
        '*password*',
29
        '*token*',
30
        '*secret*',
31
        '*hash*',
32
    ];
33
34
    /**
35
     * Checks if the given key/value is a 'UnretrieableAttribute'.
36
     *
37
     * @param  string $key
38
     * @param  array|null|string $value
39
     * @param  array $unretrievableAttributes
40
     *
41
     * @return array
42
     */
43 4
    public function getValue(string $key, $value, array $unretrievableAttributes): array
44
    {
45 4
        if (is_string($key) && Str::is(self::$unretrievableAttributesKeys, $key)) {
46
            $unretrievableAttributes[] = $key;
47
        }
48
49 4
        return $unretrievableAttributes;
50
    }
51
}
52