Passed
Push — master ( 8a455a...42a228 )
by Craig
07:01
created

AjaxUpgradeController::finalizeParameters()   C

Complexity

Conditions 11
Paths 256

Size

Total Lines 58
Code Lines 33

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 11
eloc 33
c 1
b 0
f 0
nc 256
nop 0
dl 0
loc 58
rs 5.7833

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Zikula package.
7
 *
8
 * Copyright Zikula Foundation - https://ziku.la/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Zikula\Bundle\CoreInstallerBundle\Controller;
15
16
use Symfony\Component\DependencyInjection\ContainerInterface;
17
use Symfony\Component\HttpFoundation\JsonResponse;
18
use Symfony\Component\HttpFoundation\Request;
19
use Zikula\Bundle\CoreBundle\YamlDumper;
20
use Zikula\Bundle\CoreInstallerBundle\Helper\ParameterHelper;
21
use Zikula\Bundle\CoreInstallerBundle\Helper\StageHelper;
22
23
/**
24
 * Class AjaxUpgradeController
25
 */
26
class AjaxUpgradeController extends AbstractController
27
{
28
    /**
29
     * @var YamlDumper
30
     */
31
    private $yamlManager;
32
33
    /**
34
     * @var StageHelper
35
     */
36
    private $stageHelper;
37
38
    public function __construct(ContainerInterface $container)
39
    {
40
        parent::__construct($container);
41
        $this->yamlManager = $container->get(ParameterHelper::class)->getYamlManager();
42
        $this->stageHelper = $container->get(StageHelper::class);
43
    }
44
45
    public function ajaxAction(Request $request): JsonResponse
46
    {
47
        $stage = $request->request->get('stage');
48
        $this->yamlManager->setParameter('upgrading', true);
49
        $status = $this->stageHelper->executeStage($stage);
50
51
        return new JsonResponse(['status' => $status]);
52
    }
53
}
54