Stencil_Hierarchy_Author   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 100 %

Coupling/Cohesion

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 18 18 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
 * Author hierarchy tree
4
 *
5
 * @package Stencil\Hierarchy
6
 */
7
8
/**
9
 * Class Stencil_Hierarchy_Author
10
 */
11 View Code Duplication
class Stencil_Hierarchy_Author extends Stencil_Abstract_Hierarchy {
12
	/**
13
	 * Stencil_Hierarchy_Author constructor.
14
	 */
15
	public function __construct() {
16
		$options = array();
17
18
		$author = get_queried_object();
19
20
		if ( is_a( $author, 'WP_User' ) ) {
21
			$options[] = 'single/author' . $author->user_nicename;
22
			$options[] = 'author-' . $author->user_nicename;
23
24
			$options[] = 'single/author' . $author->ID;
25
			$options[] = 'author-' . $author->ID;
26
		}
27
28
		$options[] = 'archive/author';
29
		$options[] = 'author';
30
31
		$this->set_options( $options );
32
	}
33
}
34