Completed
Push — master ( a5155e...b88100 )
by Guillaume
02:43
created

TestCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 55
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 4 1
B execute() 0 43 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: DIEU
5
 * Date: 07/02/2017
6
 * Time: 00:40
7
 */
8
9
namespace Starkerxp\StructureBundle\Command;
10
11
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
12
use Symfony\Component\Console\Input\InputInterface;
13
use Symfony\Component\Console\Output\OutputInterface;
14
use Symfony\Component\Yaml\Yaml;
15
16
//I'm includng the yml dumper. Then :
17
18
class TestCommand extends ContainerAwareCommand
19
{
20
21
    protected function configure()
22
    {
23
        $this->setName('test');
24
    }
25
26
27
    protected function execute(InputInterface $input, OutputInterface $output)
28
    {
29
        $ymlDump = [
30
            "services" => [
31
                "starker_campagne.manager.campagne" => [
32
                    "class"     => "Starkerxp\\CampagneBundle\\Manager\\CampagneManager",
33
                    "arguments" => [
34
                        "@doctrine.orm.entity_manager",
35
                        "Starkerxp\\CampagneBundle\\Entity\\Campagne",
36
                    ],
37
                    "tags"      => [
38
                        "name" => "starkerxp.manager.entity",
39
                    ],
40
                ],
41
            ],
42
        ];
43
44
45
        $yaml = Yaml::dump($ymlDump, 3, 4, 3);
46
        $path = './test.yml';
47
        file_put_contents($path, $yaml);
48
49
        // On récupère le contenu du fichier yml.
50
        $ymlDump = Yaml::parse(file_get_contents($path));
0 ignored issues
show
Unused Code introduced by
$ymlDump 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...
51
        $ymlDump2 = [
0 ignored issues
show
Unused Code introduced by
$ymlDump2 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...
52
            "services" => [
53
                "starker_campagne.manager.template" => [
54
                    "class"     => "Starkerxp\\CampagneBundle\\Manager\\TemplateManager",
55
                    "arguments" => [
56
                        "@doctrine.orm.entity_manager",
57
                        "Starkerxp\\CampagneBundle\\Entity\\Template",
58
                    ],
59
                    "tags"      => [
60
                        "name" => "starkerxp.manager.entity",
61
                    ],
62
                ],
63
            ],
64
        ];
65
66
        $path = './test.yml';
67
        file_put_contents($path, $yaml);
68
69
    }
70
71
72
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
73