Completed
Push — master ( ba40ee...261a9c )
by Tobias
02:47
created

ContainerAwareTrans::enterNode()   A

Complexity

Conditions 5
Paths 4

Size

Total Lines 19

Duplication

Lines 19
Ratio 100 %

Code Coverage

Tests 11
CRAP Score 5

Importance

Changes 0
Metric Value
dl 19
loc 19
ccs 11
cts 11
cp 1
rs 9.3222
c 0
b 0
f 0
cc 5
nc 4
nop 1
crap 5
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\Php\Symfony;
13
14
use PhpParser\Node;
15
use PhpParser\NodeVisitor;
16
use Translation\Extractor\Visitor\Php\BasePHPVisitor;
17
18
/**
19
 * @author Tobias Nyholm <[email protected]>
20
 */
21 View Code Duplication
final class ContainerAwareTrans extends BasePHPVisitor implements NodeVisitor
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 4
    public function beforeTraverse(array $nodes)
24
    {
25 4
    }
26
27 4
    public function enterNode(Node $node)
28
    {
29 4
        if (!$node instanceof Node\Expr\MethodCall) {
30 4
            return;
31
        }
32
33 4
        if (!is_string($node->name) && !$node->name instanceof Node\Identifier) {
34 1
            return;
35
        }
36 4
        $name = (string) $node->name;
37
38
        //If $this->get('translator')->trans('foobar')
0 ignored issues
show
Unused Code Comprehensibility introduced by
77% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
39 4
        if ('trans' === $name) {
40 4
            $label = $this->getStringArgument($node, 0);
41 4
            $domain = $this->getStringArgument($node, 2);
42
43 4
            $this->addLocation($label, $node->getAttribute('startLine'), $node, ['domain' => $domain]);
44
        }
45 4
    }
46
47 4
    public function leaveNode(Node $node)
48
    {
49 4
    }
50
51 4
    public function afterTraverse(array $nodes)
52
    {
53 4
    }
54
}
55