Completed
Pull Request — develop (#27)
by Chris
02:25
created

TextStream::__construct()   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 implements StreamInterface
6
{
7
    private $lines;
8
9
    public function __construct($text = '')
10
    {
11
        $this->lines = explode("\n", $text);
12
    }
13
14
    public function goNext()
15
    {
16
        next($this->lines);
17
    }
18
19
    public function isValid()
20
    {
21
        return false !== current($this->lines);
22
    }
23
24
    public function getLine()
25
    {
26
        return current($this->lines);
27
    }
28
29
    public function putLine($line)
30
    {
31
        $this->lines[] = $line;
32
    }
33
34
    public function __toString()
35
    {
36
        return implode("\n", $this->lines);
37
    }
38
}
39