Handler   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 21
rs 10
c 1
b 0
f 0
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 19 5
1
<?php
2
3
namespace Signifly\Shopify\Exceptions;
4
5
use Illuminate\Http\Client\Response;
6
use Illuminate\Support\Arr;
7
8
class Handler implements ErrorHandlerInterface
9
{
10
    public function handle(Response $response)
11
    {
12
        if ($response->successful()) {
13
            return;
14
        }
15
16
        if ($response->status() === 429) {
17
            throw new TooManyRequestsException($response);
18
        }
19
20
        if ($response->status() === 422) {
21
            throw new ValidationException(Arr::wrap($response->json('errors', [])));
22
        }
23
24
        if ($response->status() === 404) {
25
            throw new NotFoundException();
26
        }
27
28
        $response->throw();
29
    }
30
}
31