Passed
Pull Request — main (#56)
by Niels
01:53
created

InvalidRequestBodyProblemException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 33
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getViolations() 0 3 1
A jsonSerialize() 0 6 1
A __construct() 0 13 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the OpenapiBundle package.
7
 *
8
 * (c) Niels Nijens <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Nijens\OpenapiBundle\ExceptionHandling\Exception;
15
16
use Throwable;
17
18
final class InvalidRequestBodyProblemException extends ProblemException
19
{
20
    /**
21
     * @var ViolationInterface[]
22
     */
23
    private $violations;
24
25
    public function __construct(
26
        string $typeUri,
27
        string $title,
28
        int $statusCode,
29
        string $message = '',
30
        Throwable $previous = null,
31
        ?string $instanceUri = null,
32
        array $headers = [],
33
        array $violations = []
34
    ) {
35
        parent::__construct($typeUri, $title, $statusCode, $message, $previous, $instanceUri, $headers);
36
37
        $this->violations = $violations;
38
    }
39
40
    public function getViolations(): array
41
    {
42
        return $this->violations;
43
    }
44
45
    public function jsonSerialize(): array
46
    {
47
        $data = parent::jsonSerialize();
48
        $data['violations'] = $this->getViolations();
49
50
        return $data;
51
    }
52
}
53