DynamicAdapter::__call()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 3
Ratio 50 %

Importance

Changes 5
Bugs 4 Features 0
Metric Value
c 5
b 4
f 0
dl 3
loc 6
rs 9.4285
cc 2
eloc 3
nc 2
nop 2
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