PostType   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 27
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register_hooks() 0 2 1
A register_post_type() 0 2 1
1
<?php declare(strict_types = 1);
2
3
namespace WPSteak\Providers;
4
5
use WPSteak\Services\Labels;
6
7
abstract class PostType extends HookProvider {
8
9
	use Labels\PostType;
10
11
	/**
12
	 * Get args for register Post Type.
13
	 *
14
	 * This is passed for the $args attribute from register_post_type function.
15
	 * You can use the function $this->get_labels() for a easy way making your custom labels.
16
	 *
17
	 * @return array<string>
18
	 */
19
	abstract public function get_args(): array;
20
21
	/**
22
	 * Get post type.
23
	 *
24
	 * Return your Entity::POST_TYPE, for a better code reuse.
25
	 */
26
	abstract public function get_post_type(): string;
27
28
	public function register_hooks(): void {
29
		$this->add_action( 'init', 'register_post_type' );
30
	}
31
32
	protected function register_post_type(): void {
33
		register_post_type( $this->get_post_type(), $this->get_args() );
34
	}
35
36
}
37