AbstractRoutine::__construct()   A
last analyzed

Complexity

Conditions 5
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 7
cts 7
cp 1
rs 9.5555
c 0
b 0
f 0
cc 5
nc 3
nop 1
crap 5
1
<?php
2
/*
3
 * This file is part of the Respect\Rest package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace Respect\Rest\Routines;
10
11
use InvalidArgumentException;
12
13
/** Base class for callback routines */
14
abstract class AbstractRoutine implements Routinable
15
{
16
    protected $callback;
17
18 25
    public function __construct($callback)
19
    {
20 25
        if (is_string($callback) && class_exists($callback) && method_exists($callback, '__invoke')) {
21 1
            return $this->callback = $callback;
0 ignored issues
show
Bug introduced by
Constructors do not have meaningful return values, anything that is returned from here is discarded. Are you sure this is correct?
Loading history...
22
        }
23
24 24
        if (!is_callable($callback)) {
25 2
            throw new InvalidArgumentException('Routine callback must be... guess what... callable!');
26
        }
27
28 22
        $this->callback = $callback;
29 22
    }
30
31 13
    protected function getCallback()
32
    {
33 13
        return $this->callback;
34
    }
35
}
36