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