Taxonomy   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 51
rs 10
c 0
b 0
f 0
wmc 7
lcom 0
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A initializes() 0 4 1
B get() 0 20 5
A get_label_from_name() 0 3 1
1
<?php
2
3
namespace WPDFI;
4
5
/**
6
 * This class handle all actions related with taxonomy
7
 *
8
 * @author Duc Bui Quang <[email protected]>
9
 * @since 1.0.0
10
 */
11
12
use WPDFI\Traits\Singleton;
13
14
final class Taxonomy
15
{
16
	use Singleton;
17
18
	/**
19
	 * @traitDoc
20
	 */
21
	public function initializes() 
22
	{
23
		//
24
	}
25
26
	/**
27
	 * Get all taxonomy name and label by given post type name
28
	 *
29
	 * @param string $post_type
30
	 * @since 1.0.0
31
	 * @return array
32
	 */
33
	public function get($post_type) {
34
		$data = [];
35
36
		if($post_type) {
0 ignored issues
show
introduced by
Space after opening control structure is required
Loading history...
introduced by
No space before opening parenthesis is prohibited
Loading history...
introduced by
No space after opening parenthesis is prohibited
Loading history...
introduced by
No space before closing parenthesis is prohibited
Loading history...
37
			
38
			foreach(\get_object_taxonomies($post_type, 'objects') as $index => $taxonomy) {
0 ignored issues
show
introduced by
Space after opening control structure is required
Loading history...
introduced by
No space before opening parenthesis is prohibited
Loading history...
introduced by
No space after opening parenthesis is prohibited
Loading history...
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
introduced by
No space before closing parenthesis is prohibited
Loading history...
39
				// Only accept taxonomies which visible to admin and reader
40
				if($taxonomy->show_ui and $taxonomy->show_in_menu) {
0 ignored issues
show
introduced by
Space after opening control structure is required
Loading history...
introduced by
No space before opening parenthesis is prohibited
Loading history...
introduced by
No space after opening parenthesis is prohibited
Loading history...
introduced by
No space before closing parenthesis is prohibited
Loading history...
41
42
					$data[$index]['name'] = $taxonomy->name;
0 ignored issues
show
introduced by
Array keys should be surrounded by spaces unless they contain a string or an integer.
Loading history...
43
					$data[$index]['label'] = $taxonomy->label;
0 ignored issues
show
introduced by
Array keys should be surrounded by spaces unless they contain a string or an integer.
Loading history...
44
45
				}	
0 ignored issues
show
introduced by
Blank line found after control structure
Loading history...
46
47
			}
0 ignored issues
show
introduced by
Blank line found after control structure
Loading history...
48
		
49
		}
50
51
		return $data;
52
	}
53
54
	/**
55
	 * Get taxonomy label from taxonomy name
56
	 *
57
	 * @param string $taxonomy_name 
0 ignored issues
show
Bug introduced by
There is no parameter named $taxonomy_name. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
58
	 * @since 1.0.0
59
	 * @return string
60
	 */
61
	public function get_label_from_name($name) {
62
		return \get_taxonomy_labels(['name' => $name]);
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
63
	}
64
}