FlyAdapter::setSubject()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 3 Features 0
Metric Value
c 4
b 3
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
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
 * FlyAdapter
15
 *
16
 * @author Timo Michna <timomichna/yahoo.de>
17
 * @package PEIP
18
 * @subpackage base
19
 */
20
21
22
use PEIP\Data\ArrayAccess;
23
24
class FlyAdapter
25
{
26
    /**
27
     * @param $methodMap
28
     *
29
     * @return
30
     */
31
    public function __construct(ArrayAccess $methodMap)
32
    {
33
        $this->methodMap = $methodMap;
0 ignored issues
show
Bug introduced by
The property methodMap does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
34
    }
35
36
    /**
37
     * @param $subject
38
     *
39
     * @return
40
     */
41
    public function setSubject($subject)
42
    {
43
        $this->subject = $subject;
0 ignored issues
show
Bug introduced by
The property subject does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
44
45
        return $this;
46
    }
47
48
    /**
49
     * @param $method
50
     * @param $arguments
51
     *
52
     * @return
53
     */
54
    public function __call($method, $arguments)
55
    {
56 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...
57
            return call_user_func_array([$this->subject, $this->methodMap[$method]], $arguments);
58
        }
59
    }
60
}
61