Completed
Pull Request — develop (#27)
by Chris
12:14
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
 * @Target("PROPERTY")
10
 */
11
class StreamInf implements ChildCoreInterface
12
{
13
    /**
14
     * @var Chrisyue\PhpM3u8\M3u8\Core\Tag
15
     */
16
    public $tag;
17
18
    private $lines;
19
20
    public function setLines(LinesInterface $lines)
21
    {
22
        $this->lines = $lines;
23
        $this->tag->setLines($lines);
24
25
        return $this;
26
    }
27
28
    public function parse()
29
    {
30
        $result = $this->tag->parse();
31
        if (null === $result) {
32
            return;
33
        }
34
35
        $this->lines->goNext();
36
        $lineInfo = $this->lines->read();
37
        $result->uri = $lineInfo['value'];
38
39
        return $result;
40
    }
41
42
    public function dump($result)
43
    {
44
        $this->tag->dump($result);
45
46
        $this->lines->write(['value' => $result->uri]);
47
    }
48
49
    public function getSequence()
50
    {
51
        return $this->tag->getSequence();
52
    }
53
}
54