StatusFormat   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 7
dl 0
loc 18
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getVarName() 0 3 1
A getVarValue() 0 11 3
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