AuthObjectAccess   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 13
dl 0
loc 24
rs 10
c 1
b 0
f 1
wmc 8

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getGetterMapping() 0 10 4
A getSetterMapping() 0 10 4
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