Taxonomy   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register_hooks() 0 2 1
A register_taxonomy() 0 2 1
1
<?php declare(strict_types = 1);
2
3
namespace WPSteak\Providers;
4
5
use WPSteak\Services\Labels;
6
7
abstract class Taxonomy extends HookProvider {
8
9
	use Labels\Taxonomy;
10
11
	/**
12
	 * Get args for register Taxonomy.
13
	 *
14
	 * This is passed for the $args attribute from register_taxonomy 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
	 * Return your Entity::TAXONOMY, for a better code reuse.
23
	 */
24
	abstract public function get_taxonomy(): string;
25
26
	/**
27
	 * Passed for $object_type param, it can be an array or a string.
28
	 *
29
	 * @return array<string>|string
30
	 */
31
	abstract public function get_object_type();
32
33
	public function register_hooks(): void {
34
		$this->add_action( 'init', 'register_taxonomy' );
35
	}
36
37
	protected function register_taxonomy(): void {
38
		register_taxonomy( $this->get_taxonomy(), $this->get_object_type(), $this->get_args() );
39
	}
40
41
}
42