Stencil_Hierarchy_Category   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1
Metric Value
wmc 2
lcom 0
cbo 1
dl 22
loc 22
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 17 17 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * Category hierarchy tree
4
 *
5
 * @package Stencil\Hierarchy
6
 */
7
8
/**
9
 * Class Stencil_Hierarchy_Category
10
 */
11 View Code Duplication
class Stencil_Hierarchy_Category extends Stencil_Abstract_Hierarchy {
12
	/**
13
	 * Stencil_Hierarchy_Category constructor.
14
	 */
15
	public function __construct() {
16
		$category = get_queried_object();
17
18
		$options = array();
19
20
		if ( ! empty( $category->slug ) ) {
21
			$options[] = 'archive/category-' . $category->slug;
22
			$options[] = 'category-' . $category->slug;
23
24
			$options[] = 'archive/category-' . $category->term_id;
25
			$options[] = 'category-' . $category->term_id;
26
		}
27
		$options[] = 'archive/category';
28
		$options[] = 'category';
29
30
		$this->set_options( $options );
31
	}
32
}
33