Completed
Push — master ( a37b73...8ce218 )
by Chris
02:15
created

DummyM3u8Factory::createM3u8()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 1
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
ccs 10
cts 10
cp 1
crap 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\Tests;
13
14
use Chrisyue\PhpM3u8\M3u8\M3u8;
15
use Chrisyue\PhpM3u8\M3u8\MediaSegment;
16
use Chrisyue\PhpM3u8\M3u8\Playlist;
17
18
class DummyM3u8Factory
19
{
20 4
    public static function createM3u8($version = 3)
21
    {
22 4
        $playlist = new Playlist(array(
23 4
            new MediaSegment('stream12.ts', 5, 12, false, 'title'),
24 4
            new MediaSegment('stream13.ts', 4, 13),
25 4
            new MediaSegment('stream14.ts', 3, 14),
26 4
            new MediaSegment('stream15.ts', 6, 15),
27 4
            new MediaSegment('stream0.ts', 6, 16, true, null, \SplFixedArray::fromArray(array(1000, null))),
28 4
            new MediaSegment('stream0.ts', 6, 17, false, null, \SplFixedArray::fromArray(array(1000, 1000))),
29 4
        ));
30
31 4
        return new M3u8($playlist, $version, 6, 3);
32
    }
33
34 4
    public static function createM3u8Content($version = 3)
35
    {
36 4
        if ($version < 3) {
37
            return <<<'M3U8'
38
#EXTM3U
39
#EXT-X-VERSION:2
40
#EXT-X-TARGETDURATION:6
41
#EXT-X-MEDIA-SEQUENCE:12
42
#EXT-X-DISCONTINUITY-SEQUENCE:3
43
#EXTINF:5,title
44
stream12.ts
45
#EXTINF:4,
46
stream13.ts
47
#EXTINF:3,
48
stream14.ts
49
#EXTINF:6,
50
stream15.ts
51
#EXT-X-DISCONTINUITY
52
#EXTINF:6,
53
#EXT-X-BYTERANGE:1000
54
stream0.ts
55
#EXTINF:6,
56
#EXT-X-BYTERANGE:1000@1000
57
stream0.ts
58
#EXT-X-ENDLIST
59 1
M3U8;
60
        }
61
62
        return <<<'M3U8'
63
#EXTM3U
64
#EXT-X-VERSION:3
65
#EXT-X-TARGETDURATION:6
66
#EXT-X-MEDIA-SEQUENCE:12
67
#EXT-X-DISCONTINUITY-SEQUENCE:3
68
#EXTINF:5.000,title
69
stream12.ts
70
#EXTINF:4.000,
71
stream13.ts
72
#EXTINF:3.000,
73
stream14.ts
74
#EXTINF:6.000,
75
stream15.ts
76
#EXT-X-DISCONTINUITY
77
#EXTINF:6.000,
78
#EXT-X-BYTERANGE:1000
79
stream0.ts
80
#EXTINF:6.000,
81
#EXT-X-BYTERANGE:1000@1000
82
stream0.ts
83
#EXT-X-ENDLIST
84 3
M3U8;
85
    }
86
}
87