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

HandleRequestStep::requiresBefore()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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
}