Completed
Push — master ( 247290...01d05f )
by Michael
08:30
created

AbstractMock   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 81.82 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 18
loc 22
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 3 3 1
A __construct() 4 4 1
A __call() 5 8 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
/*
4
 * The RandomLib library for securely generating random numbers and strings in PHP
5
 *
6
 * @author     Anthony Ferrara <[email protected]>
7
 * @copyright  2011 The Authors
8
 * @license    http://www.opensource.org/licenses/mit-license.html  MIT License
9
 * @version    Build @@version@@
10
 */
11
12
/**
13
 * The interface that all hash implementations must implement
14
 *
15
 * PHP version 5.3
16
 *
17
 * @category   PHPPasswordLib
18
 * @package    Hash
19
 *
20
 * @author     Anthony Ferrara <[email protected]>
21
 * @copyright  2011 The Authors
22
 * @license    http://opensource.org/licenses/bsd-license.php New BSD License
23
 * @license    http://www.gnu.org/licenses/lgpl-2.1.html LGPL v 2.1
24
 */
25
namespace RandomLibtest\Mocks;
26
27
/**
28
 * The interface that all hash implementations must implement
29
 *
30
 * @category   PHPPasswordLib
31
 * @package    Hash
32
 *
33
 * @author     Anthony Ferrara <[email protected]>
34
 */
35 View Code Duplication
class AbstractMock
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...
36
{
37
    protected $callbacks = array();
38
39
    public static function init()
40
    {
41
    }
42
43
    public function __construct(array $callbacks = array())
44
    {
45
        $this->callbacks = $callbacks;
46
    }
47
48
    public function __call($name, array $args = array())
49
    {
50
        if (isset($this->callbacks[$name])) {
51
            return call_user_func_array($this->callbacks[$name], $args);
52
        }
53
54
        return null;
55
    }
56
}
57