Completed
Pull Request — develop (#27)
by Chris
04:43
created

StreamInf::setLines()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
namespace Chrisyue\PhpM3u8\M3u8\Core;
4
5
use Chrisyue\PhpM3u8\M3u8\Lines\LinesInterface;
6
7
/**
8
 * @Annotation
9
 */
10
class StreamInf implements ChildCoreInterface
11
{
12
    /**
13
     * @var Chrisyue\PhpM3u8\M3u8\Core\Tag
14
     */
15
    public $tag;
16
17
    private $lines;
18
19
    public function setLines(LinesInterface $lines)
20
    {
21
        $this->lines = $lines;
22
        $this->tag->setLines($lines);
23
24
        return $this;
25
    }
26
27
    public function parse()
28
    {
29
        $result = $this->tag->parse();
30
        if (null === $result) {
31
            return;
32
        }
33
34
        $this->lines->goNext();
35
        $lineInfo = $this->lines->read();
36
        $result->uri = $lineInfo['value'];
37
38
        return $result;
39
    }
40
41
    public function dump($result)
42
    {
43
        $this->tag->dump($result);
44
45
        $this->lines->write(['value' => $result->uri]);
46
    }
47
48
    public function getSequence()
49
    {
50
        return $this->tag->getSequence();
51
    }
52
}
53