Completed
Push — branch-7.5 ( 58010c...69c294 )
by
unknown
33:22 queued 21:52
created

Static_Call   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 38
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 38
loc 38
rs 10
c 0
b 0
f 0
wmc 8
lcom 1
cbo 2

5 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
A depends_on() 6 6 4

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
use Automattic\Jetpack\Analyzer\Declarations\Class_Method;
7
8
/**
9
 * Instantiation of a class
10
 *
11
 * TODO: detect dynamic instantiations like `$shape = new $class_name( $this->images )`
12
 */
13 View Code Duplication
class Static_Call extends PersistentListItem implements Depends_On {
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...
14
	public $path;
15
	public $line;
16
	public $class_name;
17
	public $method_name;
18
19
	public function __construct( $path, $line, $class_name, $method_name ) {
20
		$this->path = $path;
21
		$this->line = $line;
22
		$this->class_name = $class_name;
23
		$this->method_name = $method_name;
24
	}
25
26
	public function to_csv_array() {
27
		return array(
28
			$this->type(),
29
			$this->path,
30
			$this->line,
31
			$this->class_name,
32
			$this->method_name
33
		);
34
	}
35
36
	function type() {
37
		return 'static_call';
38
	}
39
40
	function display_name() {
41
		return $this->class_name . '::' . $this->method_name;
42
	}
43
44
	function depends_on( $declaration ) {
45
		return $declaration instanceof Class_Method
46
			&& $this->class_name === $declaration->class_name
47
			&& $this->method_name === $declaration->method_name
48
			&& $declaration->static;
49
	}
50
}