Passed
Push — master ( 319fcb...7a107a )
by Rafael
04:41
created

FosUserResolver::findByUsername()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
ccs 0
cts 5
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 2
1
<?php
2
/*******************************************************************************
3
 *  This file is part of the GraphQL Bundle package.
4
 *
5
 *  (c) YnloUltratech <[email protected]>
6
 *
7
 *  For the full copyright and license information, please view the LICENSE
8
 *  file that was distributed with this source code.
9
 ******************************************************************************/
10
11
namespace Ynlo\GraphQLBundle\Behat\Authentication;
12
13
use Symfony\Component\HttpKernel\Kernel;
14
15
class FosUserResolver implements UserResolverInterface
16
{
17
    /**
18
     * @var Kernel
19
     */
20
    protected $kernel;
21
22
    public function __construct(Kernel $kernel)
23
    {
24
        $this->kernel = $kernel;
25
    }
26
27
    public function findByUsername($username)
28
    {
29
        $container = $this->kernel->getContainer();
30
        $userClass = $container->getParameter('fos_user.model.user.class');
31
32
        return $container->get('doctrine')->getManager()->getRepository($userClass)->findOneBy(['username' => $username]);
33
    }
34
}
35