Passed
Branch master (022a1c)
by Darwin
03:39
created

LegacyHydrator::createUser()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 0
dl 0
loc 10
ccs 7
cts 7
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
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) {
40 5
            $user->setEnabled(true);
41 5
        }
42
43 5
        return $user;
44
    }
45
}
46