FormException::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 6
dl 0
loc 11
rs 10
1
<?php
2
3
/**
4
 * This file is part of the bugloos/error-response-bundle project.
5
 * (c) Bugloos <https://bugloos.com/>
6
 * For the full copyright and license information, please view
7
 * the LICENSE file that was distributed with this source code.
8
 */
9
10
namespace Bugloos\ErrorResponseBundle\Exception;
11
12
use Symfony\Component\Form\FormErrorIterator;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Form\FormErrorIterator was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use Symfony\Component\Form\FormInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Form\FormInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Symfony\Component\HttpFoundation\Response;
15
use Symfony\Component\HttpKernel\Exception\HttpException;
16
17
/**
18
 * @author Mojtaba Gheytasi <[email protected]>
19
 */
20
class FormException extends HttpException
21
{
22
    protected FormInterface $form;
23
24
    public function __construct(
25
        FormInterface $form,
26
        string $message = 'Invalid Form Data',
27
        int $statusCode = Response::HTTP_UNPROCESSABLE_ENTITY,
28
        \Exception $previous = null,
29
        array $headers = [],
30
        ?int $code = 0
31
    ) {
32
        parent::__construct($statusCode, $message, $previous, $headers, $code);
33
34
        $this->form = $form;
35
    }
36
37
    public function getForm(): FormInterface
38
    {
39
        return $this->form;
40
    }
41
42
    public function getErrors(): FormErrorIterator
43
    {
44
        return $this->form->getErrors(true, true);
45
    }
46
}
47