Total Complexity | 10 |
Total Lines | 103 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
16 | abstract class AbstractAdapter implements AdapterInterface |
||
17 | { |
||
18 | /** |
||
19 | * Identity. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $identifier; |
||
24 | |||
25 | /** |
||
26 | * attribute sync cache. |
||
27 | * |
||
28 | * @var int |
||
29 | */ |
||
30 | protected $attr_sync_cache = 0; |
||
31 | |||
32 | /** |
||
33 | * attribute map. |
||
34 | * |
||
35 | * @var iterable |
||
36 | */ |
||
37 | protected $map = []; |
||
38 | |||
39 | /** |
||
40 | * Identity attribute. |
||
41 | * |
||
42 | * @var string |
||
43 | */ |
||
44 | protected $identity_attribute = 'uid'; |
||
45 | |||
46 | /** |
||
47 | * Get attribute sync cache. |
||
48 | * |
||
49 | * @return int |
||
50 | */ |
||
51 | public function getAttributeSyncCache(): int |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * Set options. |
||
58 | * |
||
59 | * @param iterable $config |
||
60 | * |
||
61 | * @return AdapterInterface |
||
62 | */ |
||
63 | public function setOptions(? Iterable $config = null): AdapterInterface |
||
64 | { |
||
65 | if (null === $config) { |
||
66 | return $this; |
||
67 | } |
||
68 | |||
69 | foreach ($config as $option => $value) { |
||
70 | switch ($option) { |
||
71 | case 'map': |
||
72 | $this->map = $value; |
||
73 | |||
74 | break; |
||
75 | case 'attr_sync_cache': |
||
76 | $this->attr_sync_cache = (int) $value; |
||
77 | |||
78 | break; |
||
79 | case 'identity_attribute': |
||
80 | $this->identity_attribute = (int) $value; |
||
81 | |||
82 | break; |
||
83 | default: |
||
84 | throw new InvalidArgumentException('unknown option '.$option.' given'); |
||
85 | } |
||
86 | } |
||
87 | |||
88 | return $this; |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * Get identifier. |
||
93 | * |
||
94 | * @return string |
||
95 | */ |
||
96 | public function getIdentityAttribute(): string |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * Get identifier. |
||
103 | * |
||
104 | * @return string |
||
105 | */ |
||
106 | public function getIdentifier(): string |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * Get attribute map. |
||
113 | * |
||
114 | * @return iterable |
||
115 | */ |
||
116 | public function getAttributeMap(): Iterable |
||
121 |