Passed
Push — master ( 67aa31...d47bdf )
by Kirill
03:20
created

AbstractRenderer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 8
c 1
b 0
f 0
dl 0
loc 42
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A indent() 0 7 2
A escapeStrings() 0 3 1
A wrapContent() 0 3 1
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Debug\Renderer;
13
14
use Spiral\Debug\RendererInterface;
15
16
abstract class AbstractRenderer implements RendererInterface
17
{
18
    /**
19
     * Container element used to inject dump into, usually pre elemnt with some styling.
20
     *
21
     * @var string
22
     */
23
    protected $body = '%s';
24
25
    /**
26
     * Default indent string.
27
     *
28
     * @var string
29
     */
30
    protected $indent = '    ';
31
32
    /**
33
     * @inheritdoc
34
     */
35
    public function wrapContent(string $body): string
36
    {
37
        return sprintf($this->body, $body);
38
    }
39
40
    /**
41
     * @inheritdoc
42
     */
43
    public function indent(int $level): string
44
    {
45
        if ($level == 0) {
46
            return '';
47
        }
48
49
        return $this->apply(str_repeat($this->indent, $level), 'indent');
50
    }
51
52
    /**
53
     * @inheritdoc
54
     */
55
    public function escapeStrings(): bool
56
    {
57
        return true;
58
    }
59
}
60