ExceptionThrower::throwException()   A
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.5222
c 0
b 0
f 0
cc 5
nc 5
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Marek\OpenWeatherMap\API\Exception;
6
7
class ExceptionThrower
8
{
9
    public static function throwException($statusCode, $message)
10
    {
11
        switch ($statusCode) {
12
            case APIException::FORBIDDEN:
13
                throw new ForbiddenException($message, APIException::FORBIDDEN);
14
            case APIException::UNAUTHORIZED:
15
                throw new UnauthorizedException($message, APIException::UNAUTHORIZED);
16
            case APIException::NOT_FOUND:
17
                throw new NotFoundException($message, APIException::NOT_FOUND);
18
            case APIException::BAD_REQUEST:
19
                throw new BadRequestException($message, APIException::BAD_REQUEST);
20
        }
21
    }
22
}
23