AbstractRoutine   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
c 0
b 0
f 0
lcom 0
cbo 0
dl 0
loc 22
ccs 9
cts 9
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 5
A getCallback() 0 4 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