Passed
Pull Request — master (#4)
by Morten Poul
12:59
created

Handler::handle()   A

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
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