Passed
Push — master ( d2008b...aa9f10 )
by Atanas
01:54
created

PostSlugCondition::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 3
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 3
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace WPEmerge\Routing\Conditions;
4
5
use WPEmerge\Requests\Request;
6
7
/**
8
 * Check against the current post's slug
9
 *
10
 * @codeCoverageIgnore
11
 */
12 View Code Duplication
class PostSlugCondition implements ConditionInterface {
1 ignored issue
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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