Completed
Pull Request — develop (#30)
by
unknown
02:43
created

Segment::setProgramDateTimeTag()   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
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
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;
13
14
class Segment extends AbstractContainer
15
{
16
    private $extinfTag;
17
    private $byteRangeTag;
18
    private $discontinuityTag;
19
    private $programDateTimeTag;
20
    private $keyTags;
21
    private $uri;
22
23
    private $mediaSequence;
24
    private $discontinuitySequence;
25
26 2
    public function __construct($m3u8Version = null)
27
    {
28 2
        $this->extinfTag = new Tag\ExtinfTag($m3u8Version);
29 2
        $this->byteRangeTag = new Tag\ByteRangeTag();
30 2
        $this->discontinuityTag = new Tag\DiscontinuityTag();
31 2
        $this->programDateTimeTag = new Tag\ProgramDateTimeTag();
32 2
        $this->keyTags = new KeyTags();
33 2
        $this->uri = new Uri();
34 2
    }
35
36 1
    public function setMediaSequence($mediaSequence)
37
    {
38 1
        $this->mediaSequence = $mediaSequence;
39
40 1
        return $this;
41
    }
42
43
    public function getMediaSequence()
44
    {
45
        return $this->mediaSequence;
46
    }
47
48 1
    public function setDiscontinuitySequence($discontinuitySequence)
49
    {
50 1
        $this->discontinuitySequence = $discontinuitySequence;
51
52 1
        return $this;
53
    }
54
55
    public function getDiscontinuitySequence()
56
    {
57
        return $this->discontinuitySequence;
58
    }
59
60 2
    public function getUri()
61
    {
62 2
        return $this->uri;
63
    }
64
65
    /**
66
     * @return Chrisyue\PhpM3u8\Tag\DiscontinuityTag
67
     */
68 1
    public function getDiscontinuityTag()
69
    {
70 1
        return $this->discontinuityTag;
71
    }
72
73 1
    public function isDiscontinuity()
74
    {
75 1
        return $this->discontinuityTag->isDiscontinuity();
76
    }
77
78
    /**
79
     * @return Chrisyue\PhpM3u8\Tag\ExtinfTag
80
     */
81 2
    public function getExtinfTag()
82
    {
83 2
        return $this->extinfTag;
84
    }
85
86 1
    public function getDuration()
87
    {
88 1
        return $this->extinfTag->getDuration();
89
    }
90
91
    /**
92
     * @return Chrisyue\PhpM3u8\Tag\ByteRangeTag
93
     */
94 2
    public function getByteRangeTag()
95
    {
96 2
        return $this->byteRangeTag;
97
    }
98
99
    /**
100
     * @return Chrisyue\PhpM3u8\KeyTags
101
     */
102 2
    public function getKeyTags()
103
    {
104 2
        return $this->keyTags;
105
    }
106
107
108
    /**
109
     * @return Tag\ProgramDateTimeTag
110
     */
111
    public function getProgramDateTimeTag()
112
    {
113
        return $this->programDateTimeTag;
114
    }
115
116
    /**
117
     * @param Tag\ProgramDateTimeTag $programDateTimeTag
118
     */
119
    public function setProgramDateTimeTag(Tag\ProgramDateTimeTag $programDateTimeTag)
120
    {
121
        $this->programDateTimeTag = $programDateTimeTag;
122
    }
123
124
    /**
125
     * @return bool
126
     */
127 1
    public function isEmpty()
128
    {
129 1
        return $this->uri->isEmpty();
130
    }
131
132 2
    protected function getComponents()
133
    {
134
        return [
135 2
            $this->keyTags,
136 2
            $this->extinfTag,
137 2
            $this->byteRangeTag,
138 2
            $this->discontinuityTag,
139 2
            $this->programDateTimeTag,
140 2
            $this->uri,
141 2
        ];
142
    }
143
}
144