Auth   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 38.46 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 10
loc 26
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A setData() 10 10 2

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
 * Copyright © 2017 Toan Nguyen. All rights reserved.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace Gojira\Framework\App\Configuration;
10
11
use Gojira\Framework\Data\DataObject;
12
13
/**
14
 * Base class to work with auth config items
15
 *
16
 * @package Gojira\Framework\App\Configuration
17
 * @author  Toan Nguyen <[email protected]>
18
 */
19
class Auth extends DataObject implements AuthInterface
20
{
21
    /**
22
     * Overwrite data in the object.
23
     *
24
     * The $key parameter can be string or array.
25
     * If $key is string, the attribute value will be overwritten by $value
26
     *
27
     * If $key is an array, it will overwrite all the data in the object.
28
     *
29
     * @param string|array $key
30
     * @param mixed        $value
31
     *
32
     * @return $this
33
     */
34 View Code Duplication
    public function setData($key, $value = null)
35
    {
36
        if ($key === (array)$key) {
37
            $this->_data = $key;
38
        } else {
39
            $this->_data[$key] = $value;
40
        }
41
42
        return $this;
43
    }
44
}
45