Passed
Push — master ( b26d44...e096d1 )
by
unknown
01:42
created

QueryVar   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

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

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