Handler::handleRequestException()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 10
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0
cc 3
nc 3
nop 1
crap 12
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LauLamanApps\eCurring\Http\Adapter\Guzzle\Exception;
6
7
use GuzzleHttp\Exception\RequestException;
8
use LauLamanApps\eCurring\Exception\eCurringException;
9
10
final class Handler
11
{
12
    /**
13
     * @throws eCurringException
14
     * @throws NotFoundException
15
     */
16
    public static function handleRequestException(RequestException $exception): void
17
    {
18
        switch ($exception->getCode()) {
19
            case 400:
20
                throw new BadRequestException();
21
            case 404:
22
                throw new NotFoundException();
23
        }
24
25
        throw new eCurringException($exception->getMessage(), $exception->getCode(), $exception);
26
    }
27
}
28