Passed
Push — master ( d2008b...aa9f10 )
by Atanas
01:54
created

CustomCondition::getArguments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
3
namespace WPEmerge\Routing\Conditions;
4
5
use WPEmerge\Requests\Request;
6
7
/**
8
 * Check against a custom callable
9
 */
10
class CustomCondition 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 1
	public function __construct( $callable ) {
32 1
		$this->callable = $callable;
33 1
		$this->arguments = array_values( array_slice( func_get_args(), 1 ) );
34 1
	}
35
36
	/**
37
	 * {@inheritDoc}
38
	 */
39 1
	public function isSatisfied( Request $request ) {
40 1
		return call_user_func_array( $this->callable, $this->arguments );
41
	}
42
43
	/**
44
	 * {@inheritDoc}
45
	 */
46 1
	public function getArguments( Request $request ) {
47 1
		return $this->arguments;
48
	}
49
50
	/**
51
	 * Get the assigned callable
52
	 *
53
	 * @return callable
54
	 */
55 1
	public function getCallable() {
56 1
		return $this->callable;
57
	}
58
}
59