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

PostType::getArguments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

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
1
<?php
2
3
namespace WPEmerge\Routing\Conditions;
4
5
use WPEmerge\Request;
6
7
/**
8
 * Check against the current post's type
9
 *
10
 * @codeCoverageIgnore
11
 */
12
class PostType implements ConditionInterface {
13
	/**
14
	 * Post type to check against
15
	 *
16
	 * @var string
17
	 */
18
	protected $post_type = '';
19
20
	/**
21
	 * Constructor
22
	 *
23
	 * @param string $post_type
24
	 */
25
	public function __construct( $post_type ) {
26
		$this->post_type = $post_type;
27
	}
28
29
	/**
30
	 * {@inheritDoc}
31
	 */
32
	public function isSatisfied( Request $request ) {
33
		return ( is_singular() && $this->post_type === get_post_type() );
34
	}
35
36
	/**
37
	 * {@inheritDoc}
38
	 */
39
	public function getArguments( Request $request ) {
40
		return [$this->post_type];
41
	}
42
}
43