Passed
Pull Request — master (#4)
by Morten Poul
05:31 queued 02:55
created

Handler   A

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
7
class Handler implements ErrorHandlerInterface
8
{
9
    public function handle(Response $response)
10
    {
11
        if ($response->successful()) {
12
            return;
13
        }
14
15
        if ($response->status() === 429) {
16
            throw new TooManyRequestsException($response);
17
        }
18
19
        if ($response->status() === 422) {
20
            throw new ValidationException($response->json('errors', []));
21
        }
22
23
        if ($response->status() === 404) {
24
            throw new NotFoundException();
25
        }
26
27
        $response->throw();
28
    }
29
}
30