Completed
Branch master (755019)
by Oliver
12:48 queued 05:47
created

Callback   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 71.43%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 3
c 2
b 1
f 0
lcom 0
cbo 0
dl 0
loc 28
ccs 5
cts 7
cp 0.7143
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A __invoke() 0 6 1
1
<?php
2
3
namespace Metabor\Callback;
4
5
use InvalidArgumentException;
6
use MetaborStd\CallbackInterface;
7
8
/**
9
 * @author Oliver Tischlinger
10
 */
11
class Callback implements CallbackInterface
12
{
13
    /**
14
     * @var callable
15
     */
16
    private $callable;
17
18
    /**
19
     * @param callable $callable
20
     */
21 7
    public function __construct($callable)
22
    {
23
        if (!is_callable($callable)) {
24
            throw new InvalidArgumentException('Argument is not callable!');
25
        }
26 7
        $this->callable = $callable;
27 7
    }
28
29
    /**
30
     * @see MetaborStd.CallbackInterface::__invoke()
31
     */
32 4
    public function __invoke()
33
    {
34 4
        $args = func_get_args();
35
36
        return call_user_func_array($this->callable, $args);
37
    }
38
}
39