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

UserDataParameters::buildUserData()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

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