BaseException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 8
c 2
b 0
f 0
dl 0
loc 18
ccs 0
cts 8
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
1
<?php
2
3
namespace TarfinLabs\Parasut\Exceptions;
4
5
use Exception;
6
use Illuminate\Http\Client\Response;
7
8
abstract class BaseException extends Exception
9
{
10
    public static int $statusCode;
11
12
    /**
13
     * Create an Exception.
14
     *
15
     * @param  \Illuminate\Http\Client\Response  $response
16
     */
17
    public function __construct(Response $response)
18
    {
19
        $message = array_key_exists('error', $response->json())
20
            ? "{$response->json()['error']}: {$response->json()['error_description']}"
21
            : "{$response->json()['errors'][0]['title']}: {$response->json()['errors'][0]['detail']}";
22
23
        parent::__construct(
24
            $message,
25
            $response->status()
26
        );
27
    }
28
}
29