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

PostId   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A isSatisfied() 0 3 2
A getArguments() 0 3 1
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