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

UnprocessableEntityException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 33
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A getErrorType() 0 4 1
A getViolations() 0 4 1
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