AbstractRenderer::getConfig()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Changelog keeper
4
 *
5
 * @link      https://github.com/hiqdev/chkipper
6
 * @package   chkipper
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\chkipper\lib\renderers;
12
13
use hiqdev\chkipper\lib\ConfigInterface;
14
use hiqdev\chkipper\lib\History;
15
use hiqdev\chkipper\lib\modifiers\Normalization;
16
17
/**
18
 * Abstract history renderer.
19
 *
20
 * @author Andrii Vasyliev <[email protected]>
21
 */
22
abstract class AbstractRenderer
23
{
24
    /**
25
     * @var ConfigInterface config object
26
     */
27
    protected $_config;
28
29
    protected $normalization = Normalization::class;
30
31 2
    public function __construct(ConfigInterface $config)
32
    {
33 2
        $this->_config = $config;
34 2
    }
35
36 1
    public function getConfig()
37
    {
38 1
        return $this->_config;
39
    }
40
41 2
    public function setHistory(History $history)
42
    {
43 2
        if (!empty($this->normalization)) {
44 2
            Normalization::create($this->normalization)->run($history);
45 2
        }
46 2
        $this->_history = $history;
0 ignored issues
show
Bug Best Practice introduced by
The property _history does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
47 2
    }
48
49 2
    public function getHistory()
50
    {
51 2
        return $this->_history;
52
    }
53
54
    /**
55
     * Renders history to string.
56
     * @param History $history
57
     * @return string
58
     */
59
    abstract public function render(History $history);
60
}
61