Handler::handleRequestException()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

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