UnauthorizedHttpException::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 4
1
<?php
2
3
/*
4
 * http-exception (https://github.com/juliangut/http-exception).
5
 * HTTP aware exceptions.
6
 *
7
 * @license BSD-3-Clause
8
 * @link https://github.com/juliangut/http-exception
9
 * @author Julián Gutiérrez <[email protected]>
10
 */
11
12
declare(strict_types=1);
13
14
namespace Jgut\HttpException;
15
16
use Fig\Http\Message\StatusCodeInterface;
17
18
/**
19
 * HTTP 401 Unauthorized exception class.
20
 */
21
class UnauthorizedHttpException extends HttpException
22
{
23
    /**
24
     * @param string|null     $message
25
     * @param string|null     $description
26
     * @param int|null        $code
27
     * @param \Throwable|null $previous
28
     */
29
    public function __construct(
30
        string $message = null,
31
        string $description = null,
32
        int $code = null,
33
        \Throwable $previous = null
34
    ) {
35
        parent::__construct(
36
            $message ?? 'Unauthorized',
37
            $description ?? '',
38
            $code ?? StatusCodeInterface::STATUS_UNAUTHORIZED,
39
            StatusCodeInterface::STATUS_UNAUTHORIZED,
40
            $previous
41
        );
42
    }
43
}
44