Completed
Push — master ( a423a5...0fdb96 )
by Tobias
03:31
created

TranslationBlockTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 27.59 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 3
dl 8
loc 29
rs 10
ccs 19
cts 19
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testTrans() 0 17 1
A testTranschoice() 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\Visitor\Twig;
13
14
use Translation\Extractor\Visitor\Twig\TranslationBlock;
15
use Translation\Extractor\Visitor\Twig\TwigVisitor;
16
17
/**
18
 * @author Tobias Nyholm <[email protected]>
19
 */
20
final class TranslationBlockTest extends BaseTwigVisitorTest
21
{
22 1
    public function testTrans()
23
    {
24 1
        $collection = $this->getSourceLocations(TwigVisitor::create(), 'Twig/TranslationBlock/trans.html.twig');
25
26 1
        $this->assertCount(3, $collection);
27 1
        $source = $collection->get(0);
28 1
        $this->assertEquals('foobar', $source->getMessage());
29 1
        $this->assertEquals('domain', $source->getContext()['domain']);
30
31 1
        $source = $collection->get(1);
32 1
        $this->assertEquals('no-domain', $source->getMessage());
33 1
        $this->assertEquals('messages', $source->getContext()['domain']);
34
35 1
        $source = $collection->get(2);
36 1
        $this->assertEquals('trans-count', $source->getMessage());
37 1
        $this->assertEquals('messages', $source->getContext()['domain']);
38 1
    }
39
40 2 View Code Duplication
    public function testTranschoice()
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...
41
    {
42 1
        $collection = $this->getSourceLocations(TwigVisitor::create(), 'Twig/TranslationBlock/transchoice.html.twig');
43
44 1
        $this->assertCount(1, $collection);
45 2
        $source = $collection->first();
46 2
        $this->assertEquals('foobar', $source->getMessage());
47 1
    }
48
}
49