Completed
Push — development ( acc00d...783378 )
by Thomas
18s
created

ImportLogsController::indexAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 24
rs 9.536
c 0
b 0
f 0
1
<?php
2
3
namespace Oc\Import\Logs\Controller;
4
5
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7
use Symfony\Component\HttpFoundation\Response;
8
use Twig_Environment;
9
10
/**
11
 * @Route(service="Oc\Import\Logs\Controller\ImportLogsController")
12
 */
13
class ImportLogsController extends Controller
14
{
15
    /**
16
     * @var Twig_Environment
17
     */
18
    private $twig;
19
20
    public function __construct(Twig_Environment $twig)
21
    {
22
        $this->twig = $twig;
23
    }
24
25
    /**
26
     * @Route(path="/import/logs")
27
     */
28
    public function indexAction()
29
    {
30
        error_reporting(E_ALL);
31
        ini_set('display_errors', 'on');
32
33
        $xmlContent = file_get_contents(__DIR__ . '/../../../../../../tests/fixtures/ImportLogs/geocaching.gpx');
34
        $xmlContent = str_replace(
35
            ['<groundspeak:', '</groundspeak:'],
36
            ['<', '</'],
37
            $xmlContent
38
        );
39
        $xml = new \SimpleXMLElement($xmlContent);
40
        $xmlArray = json_decode(json_encode($xml), true);
0 ignored issues
show
Unused Code introduced by
$xmlArray 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...
41
42
        $response = new Response();
43
        $response->setContent(
44
            $this->twig->render(
45
                'importer/logs.html.twig',
46
                ['imports' => $xml]
47
            )
48
        );
49
50
        return $response;
51
    }
52
}
53