AbstractRoutine::getCallback()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
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