Passed
Push — master ( b7467b...db04eb )
by Atanas
02:41
created

Custom   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 40
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A satisfied() 0 3 1
A getArguments() 0 3 1
1
<?php
2
3
namespace Obsidian\Routing\Conditions;
4
5
use Obsidian\Request;
6
7
/**
8
 * Check against a custom callable
9
 */
10
class Custom implements ConditionInterface {
11
	/**
12
	 * Callable to use
13
	 *
14
	 * @var callable
15
	 */
16
	protected $callable = null;
17
18
	/**
19
	 * Arguments to pass to the callable and controller
20
	 *
21
	 * @var array
22
	 */
23
	protected $arguments = [];
24
25
	/**
26
	 * Constructor
27
	 *
28
	 * @param callable $callable
29
	 * @param mixed    ...$arguments
30
	 */
31
	public function __construct( $callable ) {
32
		$this->callable = $callable;
33
		$this->arguments = array_slice( func_get_args(), 1 );
34
	}
35
36
	/**
37
	 * {@inheritDoc}
38
	 */
39
	public function satisfied( Request $request ) {
40
		return call_user_func_array( $this->callable, $this->arguments );
41
	}
42
43
	/**
44
	 * {@inheritDoc}
45
	 */
46
	public function getArguments( Request $request ) {
47
		return $this->arguments;
48
	}
49
}
50