LegacyHydrator::__construct()   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 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