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

PostSlug::isSatisfied()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 3
nc 3
nop 1
dl 0
loc 4
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 slug
9
 *
10
 * @codeCoverageIgnore
11
 */
12
class PostSlug implements ConditionInterface {
13
	/**
14
	 * Post slug to check against
15
	 *
16
	 * @var string
17
	 */
18
	protected $post_slug = '';
19
20
	/**
21
	 * Constructor
22
	 *
23
	 * @param string $post_slug
24
	 */
25
	public function __construct( $post_slug ) {
26
		$this->post_slug = $post_slug;
27
	}
28
29
	/**
30
	 * {@inheritDoc}
31
	 */
32
	public function isSatisfied( Request $request ) {
33
		$post = get_post();
34
		return ( is_singular() && $post && $this->post_slug === $post->post_name );
35
	}
36
37
	/**
38
	 * {@inheritDoc}
39
	 */
40
	public function getArguments( Request $request ) {
41
		return [$this->post_slug];
42
	}
43
}
44