MetaParameters   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 11
c 1
b 0
f 0
dl 0
loc 38
rs 10

3 Methods

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