AbstractAdapter   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 97
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 1
dl 0
loc 97
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getAttributeSyncCache() 0 4 1
B setOptions() 0 23 5
A getIdentifier() 0 4 1
A getAttributeMap() 0 4 1
1
<?php
2
declare(strict_types = 1);
3
4
/**
5
 * Micro
6
 *
7
 * @author      Raffael Sahli <[email protected]>
8
 * @copyright   Copryright (c) 2017 gyselroth GmbH (https://gyselroth.com)
9
 * @license     MIT https://opensource.org/licenses/MIT
10
 */
11
12
namespace Micro\Auth\Adapter;
13
14
use \Psr\Log\LoggerInterface as Logger;
15
use \Micro\Auth\Adapter\AdapterInterface;
16
use \Micro\Auth\Exception;
17
18
abstract class AbstractAdapter implements AdapterInterface
19
{
20
    /**
21
     * Identity
22
     *
23
     * @var string
24
     */
25
    protected $identifier;
26
27
28
    /**
29
     * attribute sync cache
30
     *
31
     * @var int
32
     */
33
    protected $attr_sync_cache = 0;
34
35
36
    /**
37
     * attribute map
38
     *
39
     * @var Iterable
40
     */
41
    protected $map = [];
42
43
44
    /**
45
     * Logger
46
     *
47
     * @var Logger
48
     */
49
    protected $logger;
50
51
52
    /**
53
     * Get attribute sync cache
54
     *
55
     * @return int
56
     */
57
    public function getAttributeSyncCache(): int
58
    {
59
        return $this->attr_sync_cache;
60
    }
61
62
63
    /**
64
     * Set options
65
     *
66
     * @param   Iterable $config
67
     * @return  AdapterInterface
68
     */
69
    public function setOptions(? Iterable $config = null) : AdapterInterface
70
    {
71
        if ($config === null) {
72
            return $this;
73
        }
74
75
        foreach ($config as $option => $value) {
76
            switch ($option) {
77
                case 'map':
78
                    $this->map = $value;
79
                break;
80
81
                case 'attr_sync_cache':
82
                    $this->attr_sync_cache = (int)$value;
83
                break;
84
85
                default:
86
                    throw new Exception('unknown option '.$option.' given');
87
            }
88
        }
89
90
        return $this;
91
    }
92
93
94
    /**
95
     * Get identifier
96
     *
97
     * @return string
98
     */
99
    public function getIdentifier(): string
100
    {
101
        return $this->identifier;
102
    }
103
104
105
    /**
106
     * Get attribute map
107
     *
108
     * @return Iterable
109
     */
110
    public function getAttributeMap(): Iterable
111
    {
112
        return $this->map;
113
    }
114
}
115