Completed
Pull Request — develop (#27)
by Chris
11:56
created

DummyM3u8Factory::createM3u8Content()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 36
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 36
rs 8.8571
c 0
b 0
f 0
ccs 1
cts 1
cp 1
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\Model\MediaPlaylist;
15
use Chrisyue\PhpM3u8\Model\MediaSegment;
16
use Chrisyue\PhpM3u8\Model\Tag;
17
18
class DummyM3u8Factory
19 1
{
20
    public static function createMediaPlaylist($version = 3)
21 1
    {
22 1
        $playlist = new MediaPlaylist();
23 1
        $playlist->setVersion($version)
0 ignored issues
show
Documentation Bug introduced by
The method setMediaSequence does not exist on object<Chrisyue\PhpM3u8\Model\MediaPlaylist>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
24 1
            ->setMediaSequence(33)
25 1
            ->setDiscontinuitySequence(3)
26 1
            ->setTargetduration(12)
27
            ->setEndless(true);
28 1
29 1
        $segment = new MediaSegment($version);
0 ignored issues
show
Unused Code introduced by
The call to MediaSegment::__construct() has too many arguments starting with $version.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
30 1
31 1
        $key = new Tag\Key();
32 1
        $key->setMethod('AES-128')->setUri('key')->setIv('0xF85A5066CCB442181ACACA2E862A34DC');
0 ignored issues
show
Documentation Bug introduced by
The method setMethod does not exist on object<Chrisyue\PhpM3u8\Model\Tag\Key>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
33
        $segment->getKeys()->append($key);
0 ignored issues
show
Documentation Bug introduced by
The method getKeys does not exist on object<Chrisyue\PhpM3u8\Model\MediaSegment>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
34 1
35 1
        $key = new Tag\Key();
36 1
        $key->setMethod('SAMPLE-AES')->setUri('key2')->setIv('0xF85A5066CCB442181ACACA2E862A34DC')
0 ignored issues
show
Documentation Bug introduced by
The method setMethod does not exist on object<Chrisyue\PhpM3u8\Model\Tag\Key>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
37 1
            ->setKeyformat('com.apple')->setKeyformatversions("1");
38 1
        $segment->getKeys()->append($key);
0 ignored issues
show
Documentation Bug introduced by
The method getKeys does not exist on object<Chrisyue\PhpM3u8\Model\MediaSegment>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
39
40 1
        $inf = new Tag\Inf();
41
        $inf->setDuration(12.000)->setTitle('hello world');
42
        $segment->setInf($inf);
0 ignored issues
show
Documentation Bug introduced by
The method setInf does not exist on object<Chrisyue\PhpM3u8\Model\MediaSegment>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
43 2
44
        $byterange = new Tag\Byterange();
45 2
        $byterange->setLength(10000)->setOffset(100);
46
        $segment->setByterange($byterange);
0 ignored issues
show
Documentation Bug introduced by
The method setByterange does not exist on object<Chrisyue\PhpM3u8\Model\MediaSegment>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
47
48
        $segment->setUri('stream33.ts');
0 ignored issues
show
Documentation Bug introduced by
The method setUri does not exist on object<Chrisyue\PhpM3u8\Model\MediaSegment>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
49
50
        $playlist->getSegments()->append($segment);
0 ignored issues
show
Documentation Bug introduced by
The method getSegments does not exist on object<Chrisyue\PhpM3u8\Model\MediaPlaylist>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
51
52
        $segment = new MediaSegment();
53
        $inf = new Tag\Inf();
54
        $inf->setDuration(10.000);
55
        $segment->setInf($inf)
0 ignored issues
show
Documentation Bug introduced by
The method setInf does not exist on object<Chrisyue\PhpM3u8\Model\MediaSegment>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
56
            ->setDiscontinuity(true);
57
        $segment->setUri('video01.ts');
0 ignored issues
show
Documentation Bug introduced by
The method setUri does not exist on object<Chrisyue\PhpM3u8\Model\MediaSegment>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
58 1
59
        $playlist->getSegments()->append($segment);
0 ignored issues
show
Documentation Bug introduced by
The method getSegments does not exist on object<Chrisyue\PhpM3u8\Model\MediaPlaylist>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
60
61
        return $playlist;
62
    }
63
64
    public static function createMediaPlaylistContent($version = 3)
65
    {
66
        if ($version < 3) {
67
            return <<<'M3U8'
68
#EXTM3U
69
#EXT-X-VERSION:2
70
#EXT-X-TARGETDURATION:12
71
#EXT-X-MEDIA-SEQUENCE:33
72
#EXT-X-DISCONTINUITY-SEQUENCE:3
73 1
#EXT-X-KEY:METHOD=AES-128,URI="key",IV=0xF85A5066CCB442181ACACA2E862A34DC
74
#EXT-X-KEY:METHOD=SAMPLE-AES,URI="key2",IV=0xF85A5066CCB442181ACACA2E862A34DC,KEYFORMAT="com.apple",KEYFORMATVERSIONS="1"
75
#EXTINF:12,hello world
76
#EXT-X-BYTERANGE:10000@100
77
stream33.ts
78
#EXTINF:10,
79
#EXT-X-DISCONTINUITY
80
video01.ts
81
M3U8;
82
        }
83
84
        return <<<'M3U8'
85
#EXTM3U
86
#EXT-X-VERSION:3
87
#EXT-X-TARGETDURATION:12
88
#EXT-X-MEDIA-SEQUENCE:33
89
#EXT-X-DISCONTINUITY-SEQUENCE:3
90
#EXT-X-KEY:METHOD=AES-128,URI="key",IV=0xF85A5066CCB442181ACACA2E862A34DC
91
#EXT-X-KEY:METHOD=SAMPLE-AES,URI="key2",IV=0xF85A5066CCB442181ACACA2E862A34DC,KEYFORMAT="com.apple",KEYFORMATVERSIONS="1"
92
#EXTINF:12.000,hello world
93
#EXT-X-BYTERANGE:10000@100
94
stream33.ts
95
#EXTINF:10.000,
96
#EXT-X-DISCONTINUITY
97
video01.ts
98
M3U8;
99
    }
100
101
    public static function createMasterPlaylistContent()
102
    {
103
        return <<<'M3U8'
104
#EXTM3U
105
#EXT-X-VERSION:3
106
#EXT-X-INDEPENDENT-SEGMENTS
107
#EXT-X-START:TIME-OFFSET=1.1,PRECISE=YES
108
#EXT-X-MEDIA:TYPE=AUDIO,URI="media.uri",GROUP-ID="group",LANGUAGE="zh-Hans",ASSOC-LANGUAGE="zh-Hans",NAME="name",DEFAULT=YES,AUTOSELECT=YES,FORCED=NO,INSTREAM-ID="CC1",CHARACTERISTICS="public.easy-to-read",CHANNELS="6"
109
M3U8;
110
    }
111
}
112
113