Completed
Push — develop ( 655deb...bd286b )
by Chris
07:46
created

M3u8   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 112
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 8

Test Coverage

Coverage 96%

Importance

Changes 0
Metric Value
wmc 16
lcom 1
cbo 8
dl 0
loc 112
ccs 48
cts 50
cp 0.96
rs 10
c 0
b 0
f 0

16 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A read() 0 6 1
A getVersionTag() 0 4 1
A getVersion() 0 4 1
A getTargetDurationTag() 0 4 1
A getTargetDuration() 0 4 1
A getMediaSequenceTag() 0 4 1
A getMediaSequence() 0 4 1
A getDiscontinuitySequenceTag() 0 4 1
A getDiscontinuitySequence() 0 4 1
A getSegments() 0 4 1
A getEndlistTag() 0 4 1
A isEndless() 0 4 1
A getComponents() 0 12 1
A split() 0 7 1
A getDuration() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the PhpM3u8 package.
5
 *
6
 * (c) Chrisyue <http://chrisyue.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Chrisyue\PhpM3u8;
13
14
class M3u8 extends AbstractContainer
15
{
16
    private $m3uTag;
17
    private $versionTag;
18
    private $targetDurationTag;
19
    private $mediaSequenceTag;
20
    private $discontinuitySequenceTag;
21
    private $segments;
22
    private $endlistTag;
23
24 2
    public function __construct()
25
    {
26 2
        $this->m3uTag = new Tag\M3uTag();
27 2
        $this->versionTag = new Tag\VersionTag();
28 2
        $this->targetDurationTag = new Tag\TargetDurationTag();
29 2
        $this->mediaSequenceTag = new Tag\MediaSequenceTag();
30 2
        $this->discontinuitySequenceTag = new Tag\DiscontinuitySequenceTag();
31 2
        $this->segments = new Segments($this);
32 2
        $this->endlistTag = new Tag\EndlistTag();
33 2
    }
34
35 1
    public function read($string)
36
    {
37 1
        $lines = $this->split($string);
38
39 1
        $this->readLines($lines);
40 1
    }
41
42 1
    public function getVersionTag()
43
    {
44 1
        return $this->versionTag;
45
    }
46
47 1
    public function getVersion()
48
    {
49 1
        return $this->versionTag->getVersion();
50
    }
51
52 1
    public function getTargetDurationTag()
53
    {
54 1
        return $this->targetDurationTag;
55
    }
56
57 1
    public function getTargetDuration()
58
    {
59 1
        return $this->targetDurationTag->getTargetDuration();
60
    }
61
62 1
    public function getMediaSequenceTag()
63
    {
64 1
        return $this->mediaSequenceTag;
65
    }
66
67 1
    public function getMediaSequence()
68
    {
69 1
        return $this->mediaSequenceTag->getMediaSequence();
70
    }
71
72 1
    public function getDiscontinuitySequenceTag()
73
    {
74 1
        return $this->discontinuitySequenceTag;
75
    }
76
77 1
    public function getDiscontinuitySequence()
78
    {
79 1
        return $this->discontinuitySequenceTag->getDiscontinuitySequence();
80
    }
81
82
    /**
83
     * @return Chrisyue\PhpM3u8\Segments
84
     */
85 2
    public function getSegments()
86
    {
87 2
        return $this->segments;
88
    }
89
90 1
    public function getEndlistTag()
91
    {
92 1
        return $this->endlistTag;
93
    }
94
95
    public function isEndless()
96
    {
97
        return $this->endlistTag->isEndless();
98
    }
99
100 1
    public function getDuration()
101
    {
102 1
        return $this->segments->getDuration();
103
    }
104
105 2
    protected function getComponents()
106
    {
107
        return array(
108 2
            $this->m3uTag,
109 2
            $this->versionTag,
110 2
            $this->targetDurationTag,
111 2
            $this->mediaSequenceTag,
112 2
            $this->discontinuitySequenceTag,
113 2
            $this->segments,
114 2
            $this->endlistTag,
115 2
        );
116
    }
117
118 1
    private function split($string)
119
    {
120 1
        $lines = explode("\n", $string);
121 1
        $lines = array_map('trim', $lines);
122
123 1
        return array_filter($lines);
124
    }
125
}
126