Code Duplication    Length = 20-20 lines in 2 locations

core/Container/Condition/Post_Format_Condition.php 1 location

@@ 10-29 (lines=20) @@
7
 * 
8
 * Pass an empty string as the value for this condition in order to test if the post has no format assigned
9
 */
10
class Post_Format_Condition extends Condition {
11
	
12
	/**
13
	 * Check if the condition is fulfilled
14
	 * 
15
	 * @param  array $environment
16
	 * @return bool
17
	 */
18
	public function is_fulfilled( $environment ) {
19
		$post_id = $environment['post_id'];
20
		$format = get_post_format( $post_id );
21
		$format = ( $format ) ? $format : ''; // force an empty string for falsy values to ensure strict comparisons work
22
23
		return $this->first_supported_comparer_is_correct(
24
			$format,
25
			$this->get_comparison_operator(),
26
			$this->get_value()
27
		);
28
	}
29
}

core/Container/Condition/Post_Template_Condition.php 1 location

@@ 10-29 (lines=20) @@
7
 * 
8
 * Pass "default" as the value for the default post template
9
 */
10
class Post_Template_Condition extends Condition {
11
	
12
	/**
13
	 * Check if the condition is fulfilled
14
	 * 
15
	 * @param  array $environment
16
	 * @return bool
17
	 */
18
	public function is_fulfilled( $environment ) {
19
		$post_id = $environment['post_id'];
20
		$post_template = get_post_meta( $post_id, '_wp_page_template', true );
21
		$post_template = $post_template ? $post_template : 'default';
22
23
		return $this->first_supported_comparer_is_correct(
24
			$post_template,
25
			$this->get_comparison_operator(),
26
			$this->get_value()
27
		);
28
	}
29
}