Passed
Push — master ( 517cb3...2c2725 )
by Atanas
02:15
created

QueryVar   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

3 Methods

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