Handler::handle()   A
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 19
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 9
nc 5
nop 1
dl 0
loc 19
rs 9.6111
c 1
b 0
f 0
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