Completed
Push — master ( f79648...4cc3e5 )
by Tobias
02:47
created

ContainerAwareTrans   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A newAction() 0 19 1
A getLine() 0 4 1
A getTranslatorVariable() 0 5 1
1
<?php
2
3
namespace Translation\Extractor\Tests\Resources\Php\Symfony;
4
5
class ContainerAwareTrans
6
{
7
    /**
8
     * @return array
9
     */
10
    public function newAction()
11
    {
12
        // Using container
13
        $translated = $this->get('translator')->trans('trans0');
0 ignored issues
show
Bug introduced by
The method get() does not seem to exist on object<Translation\Extra...ny\ContainerAwareTrans>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Unused Code introduced by
$translated is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
14
15
        // As a parameter
16
        $model->setMessage(
0 ignored issues
show
Bug introduced by
The variable $model does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
17
            $this->get('translator')->trans(
0 ignored issues
show
Bug introduced by
The method get() does not seem to exist on object<Translation\Extra...ny\ContainerAwareTrans>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
18
                'trans1',
19
                array(
20
                    'a' => 'x',
21
                    'b' => 'y',
22
                    'c' => 'z',
23
                )
24
            )
25
        );
26
27
        return array();
28
    }
29
30
    public function getLine()
31
    {
32
        return $this->translator->trans('trans_line');
0 ignored issues
show
Bug introduced by
The property translator does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
33
    }
34
    public function getTranslatorVariable()
35
    {
36
        $translator = $this->get('translator');
0 ignored issues
show
Bug introduced by
The method get() does not seem to exist on object<Translation\Extra...ny\ContainerAwareTrans>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
37
        $translator->trans('variable');
38
    }
39
}
40