Completed
Push — master ( db026b...56b106 )
by Oliver
04:09 queued 02:28
created

Callback::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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 8
    public function __construct($callable)
22
    {
23 8
        if (!is_callable($callable)) {
24
            throw new InvalidArgumentException('Argument is not callable!');
25
        }
26 8
        $this->callable = $callable;
27 8
    }
28
29
    /**
30
     * @see MetaborStd.CallbackInterface::__invoke()
31
     */
32 5
    public function __invoke()
33
    {
34 5
        $args = func_get_args();
35
36 5
        return call_user_func_array($this->callable, $args);
37
    }
38
}
39