Record::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 13
dl 0
loc 16
rs 9.8333
c 2
b 0
f 0
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-2024 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 <https://www.gnu.org/licenses/>.
19
 */
20
21
namespace BigBlueButton\Core;
22
23
/**
24
 * Class Record.
25
 */
26
class Record
27
{
28
    protected \SimpleXMLElement $rawXml;
29
30
    private string $recordId;
31
    private string $meetingId;
32
    private string $name;
33
    private bool $isPublished;
34
    private string $state;
35
    private float $startTime;
36
    private float $endTime;
37
38
    /**
39
     * @deprecated deprecated since 2.1.2
40
     */
41
    private string $playbackType;
42
43
    /**
44
     * @deprecated deprecated since 2.1.2
45
     */
46
    private string $playbackUrl;
47
48
    /**
49
     * @deprecated deprecated since 2.1.2
50
     */
51
    private int $playbackLength;
52
53
    /**
54
     * @var array<string, string>
55
     */
56
    private array $metas;
57
58
    public function __construct(\SimpleXMLElement $xml)
59
    {
60
        $this->rawXml         = $xml;
61
        $this->recordId       = $xml->recordID->__toString();
62
        $this->meetingId      = $xml->meetingID->__toString();
63
        $this->name           = $xml->name->__toString();
64
        $this->isPublished    = 'true' === $xml->published->__toString();
65
        $this->state          = $xml->state->__toString();
66
        $this->startTime      = (float) $xml->startTime->__toString();
67
        $this->endTime        = (float) $xml->endTime->__toString();
68
        $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

68
        /** @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...
69
        $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

69
        /** @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...
70
        $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

70
        /** @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...
71
72
        foreach ($xml->metadata->children() as $meta) {
73
            $this->metas[$meta->getName()] = $meta->__toString();
74
        }
75
    }
76
77
    public function getRecordId(): string
78
    {
79
        return $this->recordId;
80
    }
81
82
    public function getMeetingId(): string
83
    {
84
        return $this->meetingId;
85
    }
86
87
    public function getName(): string
88
    {
89
        return $this->name;
90
    }
91
92
    public function isPublished(): ?bool
93
    {
94
        return $this->isPublished;
95
    }
96
97
    public function getState(): string
98
    {
99
        return $this->state;
100
    }
101
102
    public function getStartTime(): float
103
    {
104
        return $this->startTime;
105
    }
106
107
    public function getEndTime(): float
108
    {
109
        return $this->endTime;
110
    }
111
112
    /**
113
     * @deprecated
114
     */
115
    public function getPlaybackType(): string
116
    {
117
        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

117
        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...
118
    }
119
120
    /**
121
     * @deprecated
122
     */
123
    public function getPlaybackUrl(): string
124
    {
125
        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

125
        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...
126
    }
127
128
    /**
129
     * @deprecated
130
     */
131
    public function getPlaybackLength(): int
132
    {
133
        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

133
        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...
134
    }
135
136
    /**
137
     * @return array<string, string>
138
     */
139
    public function getMetas(): array
140
    {
141
        return $this->metas;
142
    }
143
144
    /**
145
     * @return Format[]
146
     */
147
    public function getFormats(): array
148
    {
149
        $formats = [];
150
151
        foreach ($this->rawXml->playback->format as $formatXml) {
152
            if ($formatXml) {
153
                $formats[] = new Format($formatXml);
154
            }
155
        }
156
157
        return $formats;
158
    }
159
}
160