Completed
Pull Request — develop (#27)
by Chris
10:40
created

TextStream::putLine()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Chrisyue\PhpM3u8\Stream;
4
5
class TextStream extends AbstractStream
6
{
7
    private $lines;
8
9
    public function __construct($text = '')
10
    {
11
        $this->lines = explode("\n", $text);
12
    }
13
14
    public function next()
15
    {
16
        next($this->lines);
17
    }
18
19
    public function valid()
20
    {
21
        return false !== current($this->lines);
22
    }
23
24
    public function __toString()
25
    {
26
        return implode("\n", $this->lines);
27
    }
28
29
    protected function getLine()
30
    {
31
        return current($this->lines);
32
    }
33
34
    protected function putLine($line)
35
    {
36
        $this->lines[] = $line;
37
    }
38
}
39