Completed
Push — master ( b72ee4...c33233 )
by Laurens
10:45
created

UnprocessableEntityException::getViolations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LauLamanApps\IzettleApi\Exception;
6
7
use Exception;
8
9
final class UnprocessableEntityException extends Exception implements IzettleApiException
10
{
11
    /**
12
     * @var string|null
13
     */
14
    private $errorType;
15
16
    /**
17
     * @var array|null
18
     */
19
    private $violations;
20
21
    public function __construct(string $json)
22
    {
23
24
        $error = json_decode($json, true);
25
26
        parent::__construct($error['developerMessage'], 422);
27
28
        $this->errorType = $error['errorType'];
29
        $this->violations = $error['violations'];
30
    }
31
32
    public function getErrorType(): ?string
33
    {
34
        return $this->errorType;
35
    }
36
37
    public function getViolations(): ?array
38
    {
39
        return $this->violations;
40
    }
41
}
42