Passed
Pull Request — master (#25)
by Alexander
02:01
created

convertThrowableToVerboseString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\ErrorHandler;
6
7
use Throwable;
8
use Yiisoft\FriendlyException\FriendlyExceptionInterface;
9
10
abstract class ThrowableRenderer implements ThrowableRendererInterface
11
{
12 11
    protected function getThrowableName(Throwable $t): string
13
    {
14 11
        $name = get_class($t);
15
16 11
        if ($t instanceof FriendlyExceptionInterface) {
17
            $name = $t->getName() . ' (' . $name . ')';
18
        }
19
20 11
        return $name;
21
    }
22
23 10
    protected function convertThrowableToVerboseString(Throwable $t): string
24
    {
25 10
        return $this->getThrowableName($t) . " with message '{$t->getMessage()}' \n\nin "
26 10
            . $t->getFile() . ':' . $t->getLine() . "\n\n"
27 10
            . "Stack trace:\n" . $t->getTraceAsString();
28
    }
29
}
30