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

MetaParameters::buildMeta()   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 MetaParameters.
25
 */
26
abstract class MetaParameters extends BaseParameters
27
{
28
    /**
29
     * @var array
30
     */
31
    private $meta = [];
32
33
    /**
34
     * @param $key
35
     *
36
     * @return mixed
37
     */
38
    public function getMeta($key)
39
    {
40
        return $this->meta[$key];
41
    }
42
43
    /**
44
     * @param string $key
45
     * @param string $value
46
     *
47
     * @return $this
48
     */
49
    public function addMeta($key, $value)
50
    {
51
        $this->meta[$key] = $value;
52
53
        return $this;
54
    }
55
56
    /**
57
     * @param $queries
58
     */
59
    protected function buildMeta(&$queries)
60
    {
61
        if (0 !== count($this->meta)) {
62
            foreach ($this->meta as $k => $v) {
63
                if (!is_bool($v)) {
64
                    $queries['meta_' . $k] = $v;
65
                } else {
66
                    $queries['meta_' . $k] = $v ? 'true' : 'false';
67
                }
68
            }
69
        }
70
    }
71
}
72