emlynwest /
changelog
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * @category Library |
||
| 4 | * @license MIT http://opensource.org/licenses/MIT |
||
| 5 | * @link https://github.com/emlynwest/changelog |
||
| 6 | */ |
||
| 7 | |||
| 8 | namespace ChangeLog\IO; |
||
| 9 | |||
| 10 | use ChangeLog\AbstractIO; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Allows a native string to be used as a change log source |
||
| 14 | */ |
||
| 15 | class Native extends AbstractIO |
||
| 16 | {
|
||
| 17 | |||
| 18 | /** |
||
| 19 | * @var string|string[] |
||
| 20 | */ |
||
| 21 | protected $content; |
||
| 22 | |||
| 23 | protected $configDefaults = [ |
||
| 24 | 'line_separator' => "\n", |
||
| 25 | ]; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @param string $content |
||
| 29 | */ |
||
| 30 | 2 | public function __construct($content = '') |
|
| 31 | {
|
||
| 32 | 2 | $this->setContent($content); |
|
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * {@inheritdoc}
|
||
| 37 | */ |
||
| 38 | 2 | public function setContent($content) |
|
| 39 | {
|
||
| 40 | 2 | $this->content = $content; |
|
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * {@inheritdoc}
|
||
| 45 | */ |
||
| 46 | 1 | public function getContent() |
|
| 47 | {
|
||
| 48 | 1 | if (is_string($this->content)) |
|
| 49 | {
|
||
| 50 | 1 | return explode( |
|
| 51 | 1 | $this->getConfig('line_separator'),
|
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 52 | 1 | $this->content |
|
| 53 | 1 | ); |
|
| 54 | } |
||
| 55 | |||
| 56 | 1 | return $this->content; |
|
| 57 | } |
||
| 58 | } |
||
| 59 |