LoadFixturesSubscriber   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribedEvents() 0 4 1
A loadFixtures() 0 6 1
A __construct() 0 4 1
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\Fixtures;
12
13
use Behat\Behat\EventDispatcher\Event\ScenarioTested;
14
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
15
use Symfony\Component\HttpKernel\KernelInterface;
16
use Ynlo\GraphQLBundle\Test\FixtureLoader\FixtureLoader;
17
18
class LoadFixturesSubscriber implements EventSubscriberInterface
19
{
20
    /**
21
     * @var KernelInterface
22
     */
23
    protected $kernel;
24
25
    /**
26
     * @var FixtureManager
27
     */
28
    protected $fixtureManager;
29
30
    /**
31
     * LoadFixturesSubscriber constructor.
32
     *
33
     * @param KernelInterface $kernel
34
     */
35
    public function __construct(KernelInterface $kernel, FixtureManager $fixtureManager)
36
    {
37
        $this->kernel = $kernel;
38
        $this->fixtureManager = $fixtureManager;
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public static function getSubscribedEvents()
45
    {
46
        return [
47
            ScenarioTested::BEFORE => 'loadFixtures',
48
        ];
49
    }
50
51
    public function loadFixtures()
52
    {
53
        $container = $this->kernel->getContainer();
54
        $registry = $container->get('doctrine');
55
        $fixturesLoader = new FixtureLoader($container, $registry);
0 ignored issues
show
Bug introduced by
It seems like $registry can also be of type null; however, parameter $registry of Ynlo\GraphQLBundle\Test\...reLoader::__construct() does only seem to accept Doctrine\Bundle\DoctrineBundle\Registry, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

55
        $fixturesLoader = new FixtureLoader($container, /** @scrutinizer ignore-type */ $registry);
Loading history...
56
        $this->fixtureManager->setRepository($fixturesLoader->loadFixtures());
57
    }
58
}