Completed
Pull Request — master (#17)
by Tobias
03:13 queued 01:27
created

BladeTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 52.17 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
lcom 1
cbo 4
dl 24
loc 46
ccs 29
cts 29
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getSourceLocations() 0 16 2
A testExtractLang() 8 8 1
A testExtractTrans() 8 8 1
A testExtractTransChoice() 8 8 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
/*
4
 * This file is part of the PHP Translation package.
5
 *
6
 * (c) PHP Translation team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Translation\Extractor\Tests\Functional;
13
14
use Symfony\Component\Finder\Finder;
15
use Translation\Extractor\FileExtractor\BladeFileExtractor;
16
use Translation\Extractor\Model\SourceCollection;
17
18
class BladeTest extends \PHPUnit_Framework_TestCase
19
{
20 3
    private function getSourceLocations($relativePath)
21
    {
22 3
        $extractor = new BladeFileExtractor();
23
24 3
        $filename = substr($relativePath, 1 + strrpos($relativePath, '/'));
25 3
        $path = __DIR__.'/../Resources/'.substr($relativePath, 0, strrpos($relativePath, '/'));
26
27 3
        $finder = new Finder();
28 3
        $finder->files()->name($filename)->in($path);
29 3
        $collection = new SourceCollection();
30 3
        foreach ($finder as $file) {
31 3
            $extractor->getSourceLocations($file, $collection);
32 3
        }
33
34 3
        return $collection;
35
    }
36
37 1 View Code Duplication
    public function testExtractLang()
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...
38
    {
39 1
        $collection = $this->getSourceLocations('Blade/lang.blade.php');
40
41 1
        $this->assertCount(1, $collection);
42 1
        $source = $collection->first();
43 1
        $this->assertEquals('foo.bar', $source->getMessage());
44 1
    }
45
46 1 View Code Duplication
    public function testExtractTrans()
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...
47
    {
48 1
        $collection = $this->getSourceLocations('Blade/trans.blade.php');
49
50 1
        $this->assertCount(1, $collection);
51 1
        $source = $collection->first();
52 1
        $this->assertEquals('foo.bar', $source->getMessage());
53 1
    }
54
55 1 View Code Duplication
    public function testExtractTransChoice()
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...
56
    {
57 1
        $collection = $this->getSourceLocations('Blade/trans_choice.blade.php');
58
59 1
        $this->assertCount(1, $collection);
60 1
        $source = $collection->first();
61 1
        $this->assertEquals('foo.bar', $source->getMessage());
62 1
    }
63
}
64