Passed
Pull Request — master (#9)
by Roman
03:21
created

HandleRequestStep   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 11 2
A requiresBefore() 0 3 1
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
    public function execute()
14
    {
15
        /** @var Form $form */
16
        $form = $this->getFromResponse('form');
17
        $form->handleRequest($this->request);
18
19
        if (!$form->isSubmitted()) {
20
            throw new BadRequestHttpException('Form is supposed to be submitted with this request');
21
        }
22
23
        return $this->createResponse(['form' => $form]);
24
    }
25
26
    public function requiresBefore()
27
    {
28
        return ['generic_build_form_step'];
29
    }
30
31
}