AbstractHydrator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 37
ccs 10
cts 10
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A hydrate() 0 11 2
A setAttributeMap() 0 3 1
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