Completed
Pull Request — develop (#27)
by Chris
01:41
created

StreamInf   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 43
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A parse() 0 13 2
A dump() 0 6 1
A getSequence() 0 4 1
A setLines() 0 7 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