Passed
Push — master ( 8b7547...d71e56 )
by Alexander
02:06
created

PlainTextRenderer::renderVerbose()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\ErrorHandler\Renderer;
6
7
use Psr\Http\Message\ServerRequestInterface;
8
use Throwable;
9
use Yiisoft\ErrorHandler\ErrorData;
10
use Yiisoft\ErrorHandler\ThrowableRendererInterface;
11
12
use function get_class;
13
14
/**
15
 * Formats throwable into plain text string.
16
 */
17
final class PlainTextRenderer implements ThrowableRendererInterface
18
{
19 6
    public function render(Throwable $t, ServerRequestInterface $request = null): ErrorData
20
    {
21 6
        return new ErrorData(self::DEFAULT_ERROR_MESSAGE);
22
    }
23
24 13
    public function renderVerbose(Throwable $t, ServerRequestInterface $request = null): ErrorData
25
    {
26 13
        return new ErrorData(
27 13
            get_class($t) . " with message '{$t->getMessage()}' \n\nin "
28 13
            . $t->getFile() . ':' . $t->getLine() . "\n\n"
29 13
            . "Stack trace:\n" . $t->getTraceAsString()
30
        );
31
    }
32
}
33