Completed
Push — milestone/2_0/container-condit... ( af96ef...c41f81 )
by
unknown
03:01
created

Post_Parent_ID_Condition   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A is_fulfilled() 0 10 2
1
<?php
2
3
namespace Carbon_Fields\Container\Condition;
4
5
/**
6
 * Check if post has a specific parent
7
 */
8
class Post_Parent_ID_Condition extends Condition {
9
	
10
	/**
11
	 * Check if the condition is fulfilled
12
	 * 
13
	 * @param  array $environment
14
	 * @return bool
15
	 */
16
	public function is_fulfilled( $environment ) {
17
		$post = $environment['post'];
18
		$post_parent_id = is_object( $post ) ? intval( $post->post_parent ) : 0;
19
20
		return $this->first_supported_comparer_is_correct(
21
			$post_parent_id,
22
			$this->get_comparison_operator(),
23
			$this->get_value()
24
		);
25
	}
26
}