Completed
Push — develop ( 39675e...5a1eb7 )
by David
02:50
created

Sync_Post_Adapter::is_published()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Wordlift\Dataset;
4
5
use Wordlift\Object_Type_Enum;
6
7
class Sync_Post_Adapter extends Abstract_Sync_Object_Adapter {
8
	/**
9
	 * @var int
10
	 */
11
	private $post_id;
12
13
	/**
14
	 * Sync_User_Adapter constructor.
15
	 *
16
	 * @param int $post_id
17
	 *
18
	 * @throws \Exception
19
	 */
20
	function __construct( $post_id ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
21
		parent::__construct( Object_Type_Enum::POST, $post_id );
22
23
		$this->post_id = $post_id;
24
	}
25
26
	function is_published() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
27
		return ( 'publish' === get_post_status( $this->post_id ) );
28
	}
29
30
	function is_public() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
31
		// Check if the post type is public.
32
		$post_type     = get_post_type( $this->post_id );
33
		$post_type_obj = get_post_type_object( $post_type );
34
35
		return $post_type_obj->public;
36
	}
37
38
}
39