MslsPostType   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 17 3
A is_post_type() 0 3 1
1
<?php
2
/**
3
 * MslsPostType
4
 * @author Dennis Ploetner <[email protected]>
5
 * @since 0.9.8
6
 */
7
8
namespace lloc\Msls;
9
10
/**
11
 * Content types: Post types (Pages, Posts, ...)
12
 * @package Msls
13
 */
14
class MslsPostType extends MslsContentTypes {
15
16
	/**
17
	 * Constructor
18
	 * @uses get_post_types
19
	 */
20
	public function __construct() {
21
		$this->types = array_merge(
22
			[ 'post', 'page' ], // we don't need attachment, revision or nav_menu_item here
23
			get_post_types( [ 'public' => true, '_builtin' => false ], 'names', 'and' )
24
		);
25
26
		$_request = $this->get_superglobals( [ 'post_type' ] );
27
		if ( '' != $_request['post_type'] ) {
28
			$this->request = esc_attr( $_request['post_type'] );
29
		}
30
		else {
31
			$this->request = get_post_type();
32
			if ( ! $this->request ) {
33
				$this->request = 'post';
34
			}
35
		}
36
	}
37
38
	/**
39
	 * Check for post_type
40
	 * @return bool
41
	 */
42
	function is_post_type() {
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...
43
		return true;
44
	}
45
46
}
47