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

QueryVar::getArguments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

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 0
cts 2
cp 0
crap 2
1
<?php
2
3
namespace Obsidian\Routing\Conditions;
4
5
use Obsidian\Request;
6
7
/**
8
 * Check against a query var value
9
 */
10
class QueryVar implements ConditionInterface {
11
	/**
12
	 * Query var name to check against
13
	 *
14
	 * @var string
15
	 */
16
	protected $query_var = '';
17
18
	/**
19
	 * Query var value to check against
20
	 *
21
	 * @var string
22
	 */
23
	protected $value = '';
24
25
	/**
26
	 * Constructor
27
	 *
28
	 * @param string $query_var
29
	 * @param string $value
30
	 */
31
	public function __construct( $query_var, $value = '' ) {
32
		$this->query_var = $query_var;
33
		$this->value = $value;
34
	}
35
36
	/**
37
	 * {@inheritDoc}
38
	 */
39
	public function satisfied( Request $request ) {
40
		return $this->value === get_query_var( $this->query_var, '' );
41
	}
42
43
	/**
44
	 * {@inheritDoc}
45
	 */
46
	public function getArguments( Request $request ) {
47
		return [$this->query_var, $this->value];
48
	}
49
}
50