Passed
Pull Request — master (#144)
by
unknown
01:43
created

JsonRenderer   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 12
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A render() 0 10 1
1
<?php
2
namespace Yiisoft\Yii\Web\ErrorHandler;
3
4
/**
5
 * Formats exception into JSON string
6
 */
7
class JsonRenderer extends ThrowableRenderer
8
{
9 3
    public function render(\Throwable $t): string
10
    {
11 3
        return json_encode([
12 3
            'type' => get_class($t),
13 3
            'message' => $t->getMessage(),
14 3
            'code' => $t->getCode(),
15 3
            'file' => $t->getFile(),
16 3
            'line' => $t->getLine(),
17 3
            'trace' => $t->getTrace(),
18 3
        ], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
19
    }
20
}
21