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

Post_Parent_ID_Condition::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
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
}