DynamicAdapter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 9.68 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 5
Bugs 4 Features 0
Metric Value
wmc 3
c 5
b 4
f 0
lcom 0
cbo 0
dl 3
loc 31
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A __call() 3 6 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
namespace PEIP\Base;
4
5
/*
6
 * This file is part of the PEIP package.
7
 * (c) 2009-2016 Timo Michna <timomichna/yahoo.de>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
/**
14
 * DynamicAdapter.
15
 *
16
 * @author Timo Michna <timomichna/yahoo.de>
17
 */
18
class DynamicAdapter
19
{
20
    protected $methodMap;
21
22
    protected $subject;
23
24
    /**
25
     * @param $methodMap
26
     * @param $subject
27
     *
28
     * @return
29
     */
30
    public function __construct(\ArrayAccess $methodMap, $subject)
31
    {
32
        $this->methodMap = $methodMap;
33
        $this->subject = $subject;
34
    }
35
36
    /**
37
     * @param $method
38
     * @param $arguments
39
     *
40
     * @return
41
     */
42
    public function __call($method, array $arguments)
43
    {
44 View Code Duplication
        if (array_key_exists($method, $this->methodMap)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
45
            return call_user_func_array([$this->subject, $this->methodMap[$method]], $arguments);
46
        }
47
    }
48
}
49