Passed
Pull Request — master (#189)
by Ghazi
10:24
created

Record::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 16
rs 9.8333
cc 2
nc 2
nop 1
1
<?php
2
3
/*
4
 * BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
5
 *
6
 * Copyright (c) 2016-2022 BigBlueButton Inc. and by respective authors (see below).
7
 *
8
 * This program is free software; you can redistribute it and/or modify it under the
9
 * terms of the GNU Lesser General Public License as published by the Free Software
10
 * Foundation; either version 3.0 of the License, or (at your option) any later
11
 * version.
12
 *
13
 * BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
14
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15
 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public License along
18
 * with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
namespace BigBlueButton\Core;
22
23
/**
24
 * Class Record.
25
 */
26
class Record
27
{
28
    /**
29
     * @var \SimpleXMLElement
30
     */
31
    protected $rawXml;
32
33
    private $recordId;
34
    private $meetingId;
35
    private $name;
36
    private $isPublished;
37
    private $state;
38
    private $startTime;
39
    private $endTime;
40
41
    /**
42
     * @deprecated deprecated since 2.1.2
43
     */
44
    private $playbackType;
45
46
    /**
47
     * @deprecated deprecated since 2.1.2
48
     */
49
    private $playbackUrl;
50
51
    /**
52
     * @deprecated deprecated since 2.1.2
53
     */
54
    private $playbackLength;
55
    private $metas;
56
    private $formats;
57
58
    /**
59
     * Record constructor.
60
     *
61
     * @param $xml \SimpleXMLElement
62
     */
63
    public function __construct($xml)
64
    {
65
        $this->rawXml         = $xml;
66
        $this->recordId       = $xml->recordID->__toString();
67
        $this->meetingId      = $xml->meetingID->__toString();
68
        $this->name           = $xml->name->__toString();
69
        $this->isPublished    = 'true' === $xml->published->__toString();
70
        $this->state          = $xml->state->__toString();
71
        $this->startTime      = (float) $xml->startTime->__toString();
72
        $this->endTime        = (float) $xml->endTime->__toString();
73
        $this->playbackType   = $xml->playback->format->type->__toString();
0 ignored issues
show
Deprecated Code introduced by
The property BigBlueButton\Core\Record::$playbackType has been deprecated: deprecated since 2.1.2 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

73
        /** @scrutinizer ignore-deprecated */ $this->playbackType   = $xml->playback->format->type->__toString();

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
74
        $this->playbackUrl    = $xml->playback->format->url->__toString();
0 ignored issues
show
Deprecated Code introduced by
The property BigBlueButton\Core\Record::$playbackUrl has been deprecated: deprecated since 2.1.2 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

74
        /** @scrutinizer ignore-deprecated */ $this->playbackUrl    = $xml->playback->format->url->__toString();

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
75
        $this->playbackLength = (int) $xml->playback->format->length->__toString();
0 ignored issues
show
Deprecated Code introduced by
The property BigBlueButton\Core\Record::$playbackLength has been deprecated: deprecated since 2.1.2 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

75
        /** @scrutinizer ignore-deprecated */ $this->playbackLength = (int) $xml->playback->format->length->__toString();

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
76
77
        foreach ($xml->metadata->children() as $meta) {
78
            $this->metas[$meta->getName()] = $meta->__toString();
79
        }
80
    }
81
82
    /**
83
     * @return string
84
     */
85
    public function getRecordId()
86
    {
87
        return $this->recordId;
88
    }
89
90
    /**
91
     * @return string
92
     */
93
    public function getMeetingId()
94
    {
95
        return $this->meetingId;
96
    }
97
98
    /**
99
     * @return string
100
     */
101
    public function getName()
102
    {
103
        return $this->name;
104
    }
105
106
    /**
107
     * @return null|bool
108
     */
109
    public function isPublished()
110
    {
111
        return $this->isPublished;
112
    }
113
114
    /**
115
     * @return string
116
     */
117
    public function getState()
118
    {
119
        return $this->state;
120
    }
121
122
    /**
123
     * @return string
124
     */
125
    public function getStartTime()
126
    {
127
        return $this->startTime;
128
    }
129
130
    /**
131
     * @return string
132
     */
133
    public function getEndTime()
134
    {
135
        return $this->endTime;
136
    }
137
138
    /**
139
     * @return string
140
     *
141
     * @deprecated
142
     */
143
    public function getPlaybackType()
144
    {
145
        return $this->playbackType;
0 ignored issues
show
Deprecated Code introduced by
The property BigBlueButton\Core\Record::$playbackType has been deprecated: deprecated since 2.1.2 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

145
        return /** @scrutinizer ignore-deprecated */ $this->playbackType;

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
146
    }
147
148
    /**
149
     * @return string
150
     *
151
     * @deprecated
152
     */
153
    public function getPlaybackUrl()
154
    {
155
        return $this->playbackUrl;
0 ignored issues
show
Deprecated Code introduced by
The property BigBlueButton\Core\Record::$playbackUrl has been deprecated: deprecated since 2.1.2 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

155
        return /** @scrutinizer ignore-deprecated */ $this->playbackUrl;

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
156
    }
157
158
    /**
159
     * @return string
160
     *
161
     * @deprecated
162
     */
163
    public function getPlaybackLength()
164
    {
165
        return $this->playbackLength;
0 ignored issues
show
Deprecated Code introduced by
The property BigBlueButton\Core\Record::$playbackLength has been deprecated: deprecated since 2.1.2 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

165
        return /** @scrutinizer ignore-deprecated */ $this->playbackLength;

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
166
    }
167
168
    /**
169
     * @return array
170
     */
171
    public function getMetas()
172
    {
173
        return $this->metas;
174
    }
175
176
    /**
177
     * @return Format[]
178
     */
179
    public function getFormats()
180
    {
181
        if (null === $this->formats) {
182
            $this->formats = [];
183
            foreach ($this->rawXml->playback->format as $formatXml) {
184
                $this->formats[] = new Format($formatXml);
185
            }
186
        }
187
188
        return $this->formats;
189
    }
190
}
191