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

Callback::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1.037

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 6
ccs 2
cts 3
cp 0.6667
rs 9.4286
cc 1
eloc 3
nc 1
nop 0
crap 1.037
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