Completed
Push — develop ( f101a1...f94113 )
by Chris
12s
created

DummyM3u8Factory::createM3u8Content()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 32
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 32
ccs 4
cts 4
cp 1
rs 8.8571
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 1
crap 2
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\tests;
13
14
use Chrisyue\PhpM3u8\M3u8;
15
use Chrisyue\PhpM3u8\Segment;
16
17
class DummyM3u8Factory
18
{
19 1
    public static function createM3u8($version = 3)
20
    {
21 1
        $m3u8 = new M3u8();
22 1
        $m3u8->getVersionTag()->setVersion($version);
23 1
        $m3u8->getMediaSequenceTag()->setMediaSequence(33);
24 1
        $m3u8->getDiscontinuitySequenceTag()->setDiscontinuitySequence(3);
25 1
        $m3u8->getTargetDurationTag()->setTargetDuration(12);
26 1
        $m3u8->getEndlistTag()->setEndless(true);
27
28 1
        $segment = new Segment($version);
29 1
        $segment->getExtinfTag()->setDuration(12)->setTitle('hello world');
30 1
        $segment->getByteRangeTag()->setLength(10000)->setOffset(100);
31 1
        $segment->getUri()->setUri('stream33.ts');
32 1
        $m3u8->getSegments()->add($segment);
33
34 1
        $segment = new Segment($version);
35 1
        $segment->getExtinfTag()->setDuration(10);
36 1
        $segment->getDiscontinuityTag()->setDiscontinuity(true);
37 1
        $segment->getUri()->setUri('video01.ts');
38 1
        $m3u8->getSegments()->add($segment);
39
40 1
        return $m3u8;
41
    }
42
43 2
    public static function createM3u8Content($version = 3)
44
    {
45 2
        if ($version < 3) {
46
            return <<<'M3U8'
47
#EXTM3U
48
#EXT-X-VERSION:2
49
#EXT-X-TARGETDURATION:12
50
#EXT-X-MEDIA-SEQUENCE:33
51
#EXT-X-DISCONTINUITY-SEQUENCE:3
52
#EXTINF:12,hello world
53
#EXT-X-BYTERANGE:10000@100
54
stream33.ts
55
#EXTINF:10,
56
#EXT-X-DISCONTINUITY
57
video01.ts
58 1
M3U8;
59
        }
60
61
        return <<<'M3U8'
62
#EXTM3U
63
#EXT-X-VERSION:3
64
#EXT-X-TARGETDURATION:12
65
#EXT-X-MEDIA-SEQUENCE:33
66
#EXT-X-DISCONTINUITY-SEQUENCE:3
67
#EXTINF:12.000,hello world
68
#EXT-X-BYTERANGE:10000@100
69
stream33.ts
70
#EXTINF:10.000,
71
#EXT-X-DISCONTINUITY
72
video01.ts
73 1
M3U8;
74
    }
75
}
76