Total Complexity | 11 |
Total Lines | 113 |
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 | * Setup. |
||
48 | * |
||
49 | * @return bool |
||
50 | */ |
||
51 | public function setup(): bool |
||
52 | { |
||
53 | return true; |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * Get attribute sync cache. |
||
58 | * |
||
59 | * @return int |
||
60 | */ |
||
61 | public function getAttributeSyncCache(): int |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * Set options. |
||
68 | * |
||
69 | * @param iterable $config |
||
70 | * |
||
71 | * @return AdapterInterface |
||
72 | */ |
||
73 | public function setOptions(? Iterable $config = null): AdapterInterface |
||
74 | { |
||
75 | if (null === $config) { |
||
76 | return $this; |
||
77 | } |
||
78 | |||
79 | foreach ($config as $option => $value) { |
||
80 | switch ($option) { |
||
81 | case 'map': |
||
82 | $this->map = $value; |
||
83 | |||
84 | break; |
||
85 | case 'attr_sync_cache': |
||
86 | $this->attr_sync_cache = (int) $value; |
||
87 | |||
88 | break; |
||
89 | case 'identity_attribute': |
||
90 | $this->identity_attribute = $value; |
||
91 | |||
92 | break; |
||
93 | default: |
||
94 | throw new InvalidArgumentException('unknown option '.$option.' given'); |
||
95 | } |
||
96 | } |
||
97 | |||
98 | return $this; |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * Get identifier. |
||
103 | * |
||
104 | * @return string |
||
105 | */ |
||
106 | public function getIdentityAttribute(): string |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * Get identifier. |
||
113 | * |
||
114 | * @return string |
||
115 | */ |
||
116 | public function getIdentifier(): string |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * Get attribute map. |
||
123 | * |
||
124 | * @return iterable |
||
125 | */ |
||
126 | public function getAttributeMap(): Iterable |
||
131 |