CommandController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 19
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A runAction() 0 9 2
1
<?php
2
3
/*
4
 * This file is part of the AMFConsoleBundle.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace AMF\ConsoleBundle\Controller;
11
12
use AMF\ConsoleBundle\Form\Model\ConsoleApplication;
13
use Symfony\Component\HttpFoundation\JsonResponse;
14
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
15
use Symfony\Component\HttpFoundation\Request;
16
17
/**
18
 * Controller for handling a command.
19
 *
20
 * @author Amine Fattouch <[email protected]>
21
 */
22
class CommandController extends Controller
23
{
24
    /**
25
     * Runs a command with its arguments.
26
     *
27
     * @param Request $request The current http request.
28
     *
29
     * @return JsonResponse
30
     */
31
    public function runAction(Request $request)
32
    {
33
        $processed = $this->get('amf_console.console_application.form_handler')->process($request, new ConsoleApplication());
34
        if ($processed['success'] === true) {
35
            return new JsonResponse(['output' => $processed['output']]);
36
        }
37
38
        return new JsonResponse(['errors' => $processed['errors']], 400);
39
    }
40
}
41