GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( a94445...2fd420 )
by Laszlo
07:54
created

ConsoleController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 5
dl 0
loc 67
ccs 0
cts 39
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A consoleAction() 0 10 1
A execAction() 0 21 3
1
<?php
2
3
/*
4
 * This file is part of the CoreSphereConsoleBundle.
5
 *
6
 * (c) Laszlo Korte <[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 CoreSphere\ConsoleBundle\Controller;
13
14
use CoreSphere\ConsoleBundle\Contract\Executer\CommandExecuterInterface;
15
use Symfony\Bundle\FrameworkBundle\Console\Application;
16
use Symfony\Component\HttpFoundation\Request;
17
use Symfony\Component\HttpFoundation\Response;
18
use Symfony\Component\Templating\EngineInterface;
19
20
class ConsoleController
21
{
22
    /**
23
     * @var EngineInterface
24
     */
25
    private $templating;
26
27
    /**
28
     * @var CommandExecuterInterface
29
     */
30
    private $commandExecuter;
31
32
    /**
33
     * @var Application
34
     */
35
    private $application;
36
37
    /**
38
     * @var string
39
     */
40
    private $environment;
41
42
    public function __construct(
43
        EngineInterface $templating,
44
        CommandExecuterInterface $commandExecuter,
45
        Application $application,
46
        $environment
47
    ) {
48
        $this->templating = $templating;
49
        $this->commandExecuter = $commandExecuter;
50
        $this->application = $application;
51
        $this->environment = $environment;
52
    }
53
54
    public function consoleAction()
55
    {
56
        return new Response(
57
            $this->templating->render('CoreSphereConsoleBundle:Console:console.html.twig', [
58
                'working_dir' => getcwd(),
59
                'environment' => $this->environment,
60
                'commands' => $this->application->all(),
61
            ])
62
        );
63
    }
64
65
    public function execAction(Request $request)
66
    {
67
        $commands = $request->request->get('commands');
68
        $executedCommandsOutput = [];
69
70
        foreach ($commands as $command) {
71
            $result = $this->commandExecuter->execute($command);
72
            $executedCommandsOutput[] = $result;
73
74
            if (0 !== $result['error_code']) {
75
                break;
76
            }
77
        }
78
79
        return new Response(
80
            $this->templating->render(
81
                'CoreSphereConsoleBundle:Console:result.json.twig',
82
                ['commands' => $executedCommandsOutput]
83
            )
84
        );
85
    }
86
}
87