Completed
Push — add/analyzer-class-const ( 1ca9f2 )
by
unknown
170:16 queued 161:57
created

Static_Const   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 31
loc 31
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 6 6 1
A to_csv_array() 9 9 1
A type() 3 3 1
A display_name() 3 3 1

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
namespace Automattic\Jetpack\Analyzer\Invocations;
4
5
use Automattic\Jetpack\Analyzer\PersistentList\Item as PersistentListItem;
6
7
/**
8
 * Instantiation of a class
9
 *
10
 * TODO: detect dynamic instantiations like `$shape = new $class_name( $this->images )`
11
 */
12 View Code Duplication
class Static_Const extends PersistentListItem {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
	public $path;
14
	public $line;
15
	public $class_name;
16
	public $const_name;
17
18
	public function __construct( $path, $line, $class_name, $const_name ) {
19
		$this->path = $path;
20
		$this->line = $line;
21
		$this->class_name = $class_name;
22
		$this->const_name = $const_name;
23
	}
24
25
	public function to_csv_array() {
26
		return array(
27
			$this->type(),
28
			$this->path,
29
			$this->line,
30
			$this->class_name,
31
			$this->const_name
32
		);
33
	}
34
35
	function type() {
36
		return 'class_const';
37
	}
38
39
	function display_name() {
40
		return $this->class_name . '::' . $this->const_name;
41
	}
42
}