QuickCreateAction   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 39
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A doExecute() 0 8 2
A getRedirectResponse() 0 9 1
A setDefaultOptions() 0 6 1
1
<?php
2
3
namespace Pim\Bundle\CustomEntityBundle\Action;
4
5
use Symfony\Component\HttpFoundation\RedirectResponse;
6
use Symfony\Component\HttpFoundation\Request;
7
use Symfony\Component\HttpFoundation\Response;
8
use Symfony\Component\OptionsResolver\OptionsResolver;
9
10
/**
11
 * @author    Antoine Guigan <[email protected]>
12
 * @copyright 2013 Akeneo SAS (http://www.akeneo.com)
13
 * @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
14
 */
15
class QuickCreateAction extends CreateAction
16
{
17
    /**
18
     * @param Request $request
19
     *
20
     * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
21
     */
22
    public function doExecute(Request $request)
23
    {
24
        if (!$request->isXmlHttpRequest()) {
25
            return new RedirectResponse($this->getRedirectPath(null));
0 ignored issues
show
Documentation introduced by
null is of type null, but the function expects a object.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
26
        }
27
28
        return parent::doExecute($request);
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    protected function getRedirectResponse($object)
35
    {
36
        $response = array(
37
            'status' => 1,
38
            'url' => $this->getRedirectPath($object)
39
        );
40
41
        return new Response(json_encode($response));
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    protected function setDefaultOptions(OptionsResolver $resolver)
48
    {
49
        parent::setDefaultOptions($resolver);
50
51
        $resolver->setDefaults(['template' => 'PimCustomEntityBundle:CustomEntity:quickcreate.html.twig']);
52
    }
53
}
54