Passed
Pull Request — master (#27)
by Iakov
04:00
created

HandleRequestStep::execute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 0
dl 0
loc 11
ccs 6
cts 6
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Kami\ApiCoreBundle\RequestProcessor\Step\Common;
4
5
6
use Kami\ApiCoreBundle\RequestProcessor\ResponseInterface;
7
use Kami\ApiCoreBundle\RequestProcessor\Step\AbstractStep;
8
use Symfony\Component\Form\Form;
9
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
10
11
class HandleRequestStep extends AbstractStep
12
{
13 2
    public function execute()
14
    {
15
        /** @var Form $form */
16 2
        $form = $this->getFromResponse('form');
17 2
        $form->handleRequest($this->request);
18
19 2
        if (!$form->isSubmitted()) {
20 1
            throw new BadRequestHttpException('Form is supposed to be submitted with this request');
21
        }
22
23 1
        return $this->createResponse(['form' => $form]);
24
    }
25
26 1
    public function requiresBefore()
27
    {
28 1
        return ['generic_build_form_step'];
29
    }
30
31
}