AbstractHydrator::setAttributeMap()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace DoL\LdapBundle\Hydrator;
4
5
use DoL\LdapBundle\Model\LdapUserInterface;
6
7
/**
8
 * Provide a hydrator template for easy implementation.
9
 *
10
 * @author DarwinOnLine
11
 * @author Maks3w
12
 *
13
 * @see https://github.com/DarwinOnLine/DoLLdapBundle
14
 */
15
abstract class AbstractHydrator implements HydratorInterface
16
{
17
    use HydrateWithMapTrait;
18
19
    /**
20
     * @var string[]
21
     */
22
    private $attributeMap;
23
24
    /**
25
     * {@inheritdoc}
26
     */
27 6
    public function setAttributeMap(array $attributeMap)
28
    {
29 6
        $this->attributeMap = $attributeMap;
30 6
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35 5
    public function hydrate(array $ldapEntry)
36
    {
37 5
        $user = $this->createUser();
38
39 5
        $this->hydrateUserWithAttributesMap($user, $ldapEntry, $this->attributeMap);
40
41 5
        if ($user instanceof LdapUserInterface) {
42 5
            $user->setDn($ldapEntry['dn']);
43 5
        }
44
45 5
        return $user;
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    abstract protected function createUser();
52
}
53