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

PostId::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 id
9
 *
10
 * @codeCoverageIgnore
11
 */
12
class PostId implements ConditionInterface {
13
	/**
14
	 * Post id to check against
15
	 *
16
	 * @var string
17
	 */
18
	protected $post_id = '';
19
20
	/**
21
	 * Constructor
22
	 *
23
	 * @param string $post_id
24
	 */
25
	public function __construct( $post_id ) {
26
		$this->post_id = $post_id;
27
	}
28
29
	/**
30
	 * {@inheritDoc}
31
	 */
32
	public function isSatisfied( Request $request ) {
33
		return ( is_singular() && intval( $this->post_id ) === intval( get_the_ID() ) );
34
	}
35
36
	/**
37
	 * {@inheritDoc}
38
	 */
39
	public function getArguments( Request $request ) {
40
		return [$this->post_id];
41
	}
42
}
43