Completed
Push — master ( d76c5e...03e4c2 )
by Tobias
03:46
created

Twig2TranslationBlock   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 29
loc 29
ccs 0
cts 18
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A enterNode() 6 6 1
A leaveNode() 4 4 1
A getPriority() 4 4 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\Visitor\Twig;
13
14
use Translation\Extractor\Visitor\BaseVisitor;
15
use Twig_Environment;
16
use Twig_Node;
17
18
/**
19
 * @author Tobias Nyholm <[email protected]>
20
 */
21 View Code Duplication
final class Twig2TranslationBlock extends BaseVisitor implements \Twig_NodeVisitorInterface
0 ignored issues
show
Duplication introduced by
This class 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...
22
{
23
    /**
24
     * @var WorkerTranslationBlock
25
     */
26
    private $worker;
27
28
    public function __construct()
29
    {
30
        $this->worker = new WorkerTranslationBlock();
31
    }
32
33
    public function enterNode(Twig_Node $node, Twig_Environment $env)
34
    {
35
        return $this->worker->work($node, $this->collection, function () {
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->worker->work($nod...AbsoluteFilePath(); }); of type Twig_Node|Twig_NodeInterface adds the type Twig_NodeInterface to the return on line 35 which is incompatible with the return type declared by the interface Twig_NodeVisitorInterface::enterNode of type Twig_Node.
Loading history...
36
            return $this->getAbsoluteFilePath();
37
        });
38
    }
39
40
    public function leaveNode(Twig_Node $node, Twig_Environment $env)
41
    {
42
        return $node;
43
    }
44
45
    public function getPriority()
46
    {
47
        return 0;
48
    }
49
}
50