Completed
Pull Request — master (#9)
by Roman
03:37
created

ValidateFormStep   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 9 2
A requiresBefore() 0 3 1
1
<?php
2
3
namespace Kami\ApiCoreBundle\RequestProcessor\Step\Common;
4
5
use Kami\ApiCoreBundle\RequestProcessor\Step\AbstractStep;
6
use Symfony\Component\Form\Form;
7
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
8
9
class ValidateFormStep extends AbstractStep
10
{
11
    public function execute()
12
    {
13
        /** @var Form $form */
14
        $form = $this->getFromResponse('form');
15
        if (!$form->isValid()) {
16
            return $this->createResponse(['response_data' => $form->getErrors()], true, 400);
17
        }
18
19
        return $this->createResponse([]);
20
    }
21
22
    public function requiresBefore()
23
    {
24
        return [HandleRequestStep::class];
25
    }
26
27
}