CompareTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 68.57 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getXmlDefinitions() 12 12 1
A getYamlDefinitions() 12 12 1
A testFullXmlAndYamlSame() 0 6 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Mathielen\ImportEngineBundle\Tests\DependencyInjection;
4
5
use Symfony\Component\Config\FileLocator;
6
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
7
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
8
9
class CompareTest extends AbstractTest
10
{
11 View Code Duplication
    private function getXmlDefinitions($filename)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
    {
13
        $this->setUp();
14
        $container = $this->container;
15
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/Xml/'));
16
        $loader->load("$filename.xml");
17
18
        $container->loadFromExtension('mathielen_import_engine');
19
        $container->compile();
20
21
        return $container->getDefinitions();
22
    }
23
24 View Code Duplication
    private function getYamlDefinitions($filename)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
    {
26
        $this->setUp();
27
        $container = $this->container;
28
        $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/Yaml/'));
29
        $loader->load("$filename.yml");
30
31
        $container->loadFromExtension('mathielen_import_engine');
32
        $container->compile();
33
34
        return $container->getDefinitions();
35
    }
36
37
    public function testFullXmlAndYamlSame()
38
    {
39
        $this->assertEquals($this->getYamlDefinitions('full'), $this->getXmlDefinitions('full'));
40
        $this->assertEquals($this->getYamlDefinitions('medium'), $this->getXmlDefinitions('medium'));
41
        $this->assertEquals($this->getYamlDefinitions('minimum'), $this->getXmlDefinitions('minimum'));
42
    }
43
}
44
45
class MyImportedRow
46
{
47
}
48