LegacyHydrator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createUser() 0 10 2
A __construct() 0 3 1
1
<?php
2
3
namespace DoL\LdapBundle\Hydrator;
4
5
use FOS\UserBundle\Model\UserManagerInterface;
6
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
7
8
/**
9
 * Populate a FOSUserBundle user with data from LDAP.
10
 *
11
 * @author DarwinOnLine
12
 * @author Maks3w
13
 *
14
 * @see https://github.com/DarwinOnLine/DoLLdapBundle
15
 */
16
final class LegacyHydrator extends AbstractHydrator
17
{
18
    /**
19
     * @var UserManagerInterface
20
     */
21
    private $userManager;
22
23
    /**
24
     * @param UserManagerInterface $userManager
25
     */
26 6
    public function __construct($userManager)
27
    {
28 6
        $this->userManager = $userManager;
29 6
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34 5
    protected function createUser()
35
    {
36 5
        $user = $this->userManager->createUser();
37 5
        $user->setPassword('');
38
39 5
        if ($user instanceof AdvancedUserInterface) {
0 ignored issues
show
introduced by
$user is always a sub-type of Symfony\Component\Securi...r\AdvancedUserInterface.
Loading history...
40 5
            $user->setEnabled(true);
41 5
        }
42
43 5
        return $user;
44
    }
45
}
46