Completed
Pull Request — develop (#10)
by
unknown
24:24 queued 09:15
created

MediaSegment::getByteRange()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 0
cp 0
crap 2
rs 10
c 0
b 0
f 0
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\M3u8;
13
14
class MediaSegment
15
{
16
    protected $uri;
17
    protected $duration;
18
    protected $sequence;
19
    protected $isDiscontinuity;
20
    protected $title;
21
    protected $byterange;
22 4
23
    public function __construct($uri, $duration, $sequence, $isDiscontinuity = false, $title = null, $byteRangeLength = null, $byteRangeOffset = null)
24 4
    {
25 4
        $this->uri = $uri;
26 4
        $this->duration = $duration;
27 4
        $this->sequence = $sequence;
28 4
        $this->isDiscontinuity = $isDiscontinuity;
29 4
        $this->title = $title;
30
        $this->byterange = \SplFixedArray::fromArray(
31 2
            array(
32
                $byteRangeLength,
33 2
                is_null($byteRangeLength) ? null : $byteRangeOffset,
34
            ),
35
            false
36 2
        );
37
    }
38 2
39
    public function getUri()
40
    {
41 2
        return $this->uri;
42
    }
43 2
44
    public function getDuration()
45
    {
46 2
        return $this->duration;
47
    }
48 2
49
    public function getSequence()
50
    {
51 2
        return $this->sequence;
52
    }
53 2
54
    public function isDiscontinuity()
55
    {
56
        return $this->isDiscontinuity;
57
    }
58
59
    public function getTitle()
60
    {
61
        return $this->title;
62
    }
63
64
    public function getByteRange()
65
    {
66
        return ['length' => $this->byterange[0], 'offset' => $this->byterange[1]];
67
    }
68
69
    public function getByteRangeFixed()
70
    {
71
        return $this->byterange;
72
    }
73
}
74