LogController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fileAction() 0 14 2
A addFlash() 0 9 2
1
<?php
2
3
namespace FOA\CronBundle\Controller;
4
5
use Symfony\Component\HttpFoundation\Response;
6
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7
8
/**
9
 * Display and manage log files
10
 * @author Novikov Viktor
11
 */
12
class LogController extends Controller
13
{
14
    /**
15
     * Gets a log file
16
     *
17
     * @param $id   - the line of the cron in the cron table
18
     * @param $type - the type of file, log or error
19
     *
20
     * @return Response
21
     */
22
    public function fileAction($id, $type)
23
    {
24
        $cronManager = $this->get('foa.cron_bundle.cron_manager');
25
        $cron = $cronManager->getById($id);
26
        $filepath = ($type == 'log') ? $cron->getLogFile() : $cron->getErrorFile();
27
        // TODO: re-activate when secure
28
        // $content = file_get_contents($filepath);
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% 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...
29
        $content = 'File content not displayable.';
30
31
        return $this->render('FOACronBundle:Dashboard:log.html.twig', [
32
            'filepath' => $filepath,
33
            'content'  => $content,
34
        ]);
35
    }
36
37
    /**
38
     * Adds a flash to the flash bag where flashes are array of messages
39
     *
40
     * @param $type
41
     * @param $message
42
     */
43
    protected function addFlash($type, $message)
44
    {
45
        if (empty($message)) {
46
            return;
47
        }
48
49
        $session = $this->get('session');
50
        $session->getFlashBag()->add($type, $message);
51
    }
52
}
53