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

ThrowableRenderer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 88.89%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
dl 0
loc 18
ccs 8
cts 9
cp 0.8889
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A convertThrowableToVerboseString() 0 5 1
A getThrowableName() 0 9 2
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