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

New_::to_csv_array()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 9
loc 9
rs 9.9666
c 0
b 0
f 0
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_;
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 New_ 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
18
	public function __construct( $path, $line, $class_name ) {
19
		$this->path = $path;
20
		$this->line = $line;
21
		$this->class_name = $class_name;
22
	}
23
24
	public function to_csv_array() {
25
		return array(
26
			$this->type(),
27
			$this->path,
28
			$this->line,
29
			$this->class_name,
30
			''
31
		);
32
	}
33
34
	function type() {
35
		return 'new';
36
	}
37
38
	function display_name() {
39
		return 'new ' . $this->class_name;
40
	}
41
42
	function depends_on( $declaration ) {
43
		return $declaration instanceof Class_
44
			&& $this->class_name === $declaration->class_name;
45
	}
46
}