StatusFormat::getVarName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 *  This file is part of the Micro framework package.
7
 *
8
 *  (c) Stanislau Komar <[email protected]>
9
 *
10
 *  For the full copyright and license information, please view the LICENSE
11
 *  file that was distributed with this source code.
12
 */
13
14
namespace Micro\Plugin\Http\Business\Logger\Formatter\Format;
15
16
use Symfony\Component\HttpFoundation\Request;
17
use Symfony\Component\HttpFoundation\Response;
18
19
/**
20
 * @author Stanislau Komar <[email protected]>
21
 */
22
class StatusFormat extends AbstractFormat
23
{
24 6
    protected function getVarValue(Request $request, Response|null $response, ?\Throwable $exception): string
25
    {
26 6
        if (null !== $response) {
27 3
            return (string) $response->getStatusCode();
28
        }
29
30 3
        if ($exception instanceof \Throwable) {
31 2
            return (string) $exception->getCode();
32
        }
33
34 1
        return '500';
35
    }
36
37 6
    protected function getVarName(): string
38
    {
39 6
        return 'status';
40
    }
41
}
42