Completed
Pull Request — 1.5 (#758)
by Paweł
11:13
created

FixtureService   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A reloadFixtures() 0 15 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SWP\Behat\Service;
6
7
use BehatExtension\DoctrineDataFixturesExtension\Service\FixtureService as BaseFixtureService;
8
use Doctrine\ORM\Tools\SchemaTool;
9
use Symfony\Component\DependencyInjection\ContainerInterface;
10
use Symfony\Component\HttpKernel\Kernel;
11
12
final class FixtureService extends BaseFixtureService
13
{
14
    private $em;
15
16
    public function __construct(ContainerInterface $container, Kernel $kernel)
17
    {
18
        parent::__construct($container, $kernel);
19
20
        $this->em = $kernel->getContainer()->get('doctrine')->getManager();
21
    }
22
23
    public function reloadFixtures($disableFixtures = false)
24
    {
25
        if ($disableFixtures) {
26
            // Drop Database
27
            $schemaTool = new SchemaTool($this->em);
28
            $schemaTool->dropDatabase();
29
30
            //Create Database
31
            $metadata = $this->em->getMetadataFactory()->getAllMetadata();
32
            $schemaTool = new SchemaTool($this->em);
33
            $schemaTool->createSchema($metadata);
34
        } else {
35
            parent::reloadFixtures();
36
        }
37
    }
38
}
39