Completed
Push — master ( 0c1faf...c6b404 )
by Raffael
02:34
created

AbstractAdapter::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
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
17
abstract class AbstractAdapter implements AdapterInterface
18
{
19
    /**
20
     * Identity
21
     *
22
     * @var string
23
     */
24
    protected $identifier;
25
26
27
    /**
28
     * attribute sync cache
29
     *
30
     * @var int
31
     */
32
    protected $attr_sync_cache = 0;
33
34
35
    /**
36
     * attribute map
37
     *
38
     * @var Iterable
39
     */
40
    protected $map = [];
41
42
43
    /**
44
     * Logger
45
     *
46
     * @var Logger
47
     */
48
    protected $logger;
49
50
51
    /**
52
     * Get attribute sync cache
53
     *
54
     * @return int
55
     */
56
    public function getAttributeSyncCache(): int
57
    {
58
        return $this->attr_sync_cache;
59
    }
60
61
62
    /**
63
     * Set options
64
     *
65
     * @param   Iterable $config
66
     * @return  AdapterInterface
67
     */
68
    public function setOptions(? Iterable $config = null) : AdapterInterface
69
    {
70
        if ($config === null) {
71
            return $this;
72
        }
73
74
        foreach ($config as $option => $value) {
75
            switch ($option) {
76
                case 'map':
77
                    $this->map = $value;
78
                break;
79
80
                case 'attr_sync_cache':
81
                    $this->attr_sync_cache = (int)$value;
82
                break;
83
            }
84
        }
85
86
        return $this;
87
    }
88
89
90
    /**
91
     * Get identifier
92
     *
93
     * @return string
94
     */
95
    public function getIdentifier(): string
96
    {
97
        return $this->identifier;
98
    }
99
100
101
    /**
102
     * Get attribute map
103
     *
104
     * @return Iterable
105
     */
106
    public function getAttributeMap(): Iterable
107
    {
108
        return $this->map;
109
    }
110
}
111