Completed
Push — master ( ab8eaa...f461e1 )
by Ghazi
10:32
created

UserDataParameters   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 38
loc 38
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getUserData() 4 4 1
A addUserData() 6 6 1
A buildUserData() 8 8 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
4
 *
5
 * Copyright (c) 2016-2018 BigBlueButton Inc. and by respective authors (see below).
6
 *
7
 * This program is free software; you can redistribute it and/or modify it under the
8
 * terms of the GNU Lesser General Public License as published by the Free Software
9
 * Foundation; either version 3.0 of the License, or (at your option) any later
10
 * version.
11
 *
12
 * BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
13
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14
 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public License along
17
 * with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
18
 */
19
namespace BigBlueButton\Parameters;
20
21
/**
22
 * Class UserDataParameters
23
 * @package BigBlueButton\Parameters
24
 */
25 View Code Duplication
abstract class UserDataParameters extends MetaParameters
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
{
27
    /**
28
     * @var array
29
     */
30
    private $userData = [];
31
32
    /**
33
     * @param $key
34
     * @return mixed
35
     */
36
    public function getUserData($key)
37
    {
38
        return $this->userData[$key];
39
    }
40
41
    /**
42
     * @param string $key
43
     * @param string $value
44
     *
45
     * @return $this
46
     */
47
    public function addUserData($key, $value)
48
    {
49
        $this->userData[$key] = $value;
50
51
        return $this;
52
    }
53
54
    protected function buildUserData(&$queries)
55
    {
56
        if (count($this->userData) !== 0) {
57
            foreach ($this->userData as $k => $v) {
58
                $queries['userdata-' . $k] = $v;
59
            }
60
        }
61
    }
62
}
63