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

TextStream   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 34
c 0
b 0
f 0
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A goNext() 0 4 1
A isValid() 0 4 1
A getLine() 0 4 1
A putLine() 0 4 1
A __toString() 0 4 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