hiqdev /
chkipper
| 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
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 |