AuthObjectAccess::getSetterMapping()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 4
eloc 6
nc 3
nop 1
dl 0
loc 10
rs 10
c 1
b 0
f 1
1
<?php
2
3
namespace W2w\Laravel\Apie\Plugins\Illuminate\ObjectAccess;
4
5
use Illuminate\Contracts\Auth\Authenticatable;
6
use ReflectionClass;
7
use W2w\Lib\ApieObjectAccessNormalizer\ObjectAccess\ObjectAccess;
8
9
/**
10
 * ObjectAccess for Authenticatable to remove security sensitive fields from mapping.
11
 *
12
 * @see Authenticatable
13
 */
14
class AuthObjectAccess extends ObjectAccess
15
{
16
    protected function getGetterMapping(ReflectionClass $reflectionClass): array
17
    {
18
        $parent = parent::getGetterMapping($reflectionClass);
19
        $result = [];
20
        foreach ($parent as $key => $keyMapping) {
21
            if (strpos($key, 'auth') === false && strpos($key, 'remember') === false) {
22
                $result[$key] = $keyMapping;
23
            }
24
        }
25
        return $result;
26
    }
27
28
    protected function getSetterMapping(ReflectionClass $reflectionClass): array
29
    {
30
        $parent = parent::getSetterMapping($reflectionClass);
31
        $result = [];
32
        foreach ($parent as $key => $keyMapping) {
33
            if (strpos($key, 'auth') === false && strpos($key, 'remember') === false) {
34
                $result[$key] = $keyMapping;
35
            }
36
        }
37
        return $result;
38
    }
39
}
40