Identity::getAdapter()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
declare(strict_types = 1);
3
4
/**
5
 * Micro
6
 *
7
 * @author    Raffael Sahli <[email protected]>
8
 * @copyright Copyright (c) 2017 gyselroth GmbH (https://gyselroth.com)
9
 * @license   MIT https://opensource.org/licenses/MIT
10
 */
11
12
namespace Micro\Auth;
13
14
use \Micro\Auth\Exception;
15
use \Micro\Auth\Adapter\AdapterInterface;
16
use \Psr\Log\LoggerInterface as Logger;
17
18
class Identity
19
{
20
    /**
21
     * Attribute map
22
     *
23
     * @var AttributeMap
24
     */
25
    private $attribute_map;
26
27
28
    /**
29
     * Auth adapter
30
     *
31
     * @var AdapterInterface
32
     */
33
    private $adapter;
34
35
36
    /**
37
     * Logger
38
     *
39
     * @var Logger
40
     */
41
    protected $logger;
42
43
44
    /**
45
     * Initialize
46
     *
47
     * @param   AdapterInterface $adapter
48
     * @param   AttributeMap $map
49
     * @param   Logger $logger
50
     * @return  void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
51
     */
52
    public function __construct(AdapterInterface $adapter, AttributeMap $map, Logger $logger)
53
    {
54
        $this->attribute_map = $map;
55
        $this->logger        = $logger;
56
        $this->adapter       = $adapter;
57
    }
58
59
    
60
    /**
61
     * Get attribute map
62
     *
63
     * @return AttributeMap
64
     */
65
    public function getAttributeMap(): AttributeMap
66
    {
67
        return $this->attribute_map;
68
    }
69
70
71
    /**
72
     * Get adapter
73
     *
74
     * @return AdapterInterface
75
     */
76
    public function getAdapter(): AdapterInterface
77
    {
78
        return $this->adapter;
79
    }
80
81
82
    /**
83
     * Get identity
84
     *
85
     * @return string
86
     */
87
    public function getIdentifier(): string
88
    {
89
        return $this->adapter->getIdentifier();
90
    }
91
92
93
    /**
94
     * Get identity attributes
95
     *
96
     * @return array
97
     */
98
    public function getAttributes(): array
99
    {
100
        return $this->attribute_map->map($this->adapter->getAttributes());
101
    }
102
}
103