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

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