UserDataParameters::buildUserData()   A
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 8
rs 9.6111
c 2
b 0
f 0
cc 5
nc 5
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\Parameters;
22
23
abstract class UserDataParameters extends BaseParameters
24
{
25
    /**
26
     * @var array<string, mixed>
27
     */
28
    private array $userData = [];
29
30
    /**
31
     * @return mixed
32
     */
33
    public function getUserData(string $key)
34
    {
35
        return $this->userData[$key];
36
    }
37
38
    /**
39
     * @param mixed $value
40
     *
41
     * @return $this
42
     */
43
    public function addUserData(string $key, $value): self
44
    {
45
        $this->userData[$key] = $value;
46
47
        return $this;
48
    }
49
50
    /**
51
     * @param mixed $queries
52
     */
53
    protected function buildUserData(&$queries): void
54
    {
55
        if (0 !== count($this->userData)) {
56
            foreach ($this->userData as $key => $value) {
57
                if (!is_bool($value)) {
58
                    $queries['userdata-' . $key] = $value;
59
                } else {
60
                    $queries['userdata-' . $key] = $value ? 'true' : 'false';
61
                }
62
            }
63
        }
64
    }
65
}
66