Passed
Push — main ( cd5116...99c066 )
by Dimitri
12:52
created

HttpException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 25%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 20
ccs 1
cts 4
cp 0.25
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A invalidStatusCode() 0 3 1
A badRequest() 0 3 1
A methodNotAllowed() 0 3 1
A invalidRedirectRoute() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of Blitz PHP framework.
5
 *
6
 * (c) 2022 Dimitri Sitchet Tomkeu <[email protected]>
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 */
11
12
namespace BlitzPHP\Exceptions;
13
14
class HttpException extends FrameworkException
15
{
16
    public static function methodNotAllowed(string $method): self
17
    {
18
        return new static(self::lang('HTTP.methodNotAllowed', [$method]));
19
    }
20
21
    public static function invalidStatusCode(int $code)
22
    {
23
        return new static(lang('HTTP.invalidStatusCode', [$code]));
24
    }
25
26
    public static function invalidRedirectRoute(string $route)
27
    {
28 4
        return new static(lang('HTTP.invalidRoute', [$route]));
29
    }
30
31
    public static function badRequest(string $message = 'Bad Request')
32
    {
33
        return new static($message, 400);
34
    }
35
}
36