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

Static_Const::depends_on()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 1
dl 0
loc 5
rs 10
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_Const;
7
8
/**
9
 * Instantiation of a class
10
 *
11
 * TODO: detect dynamic instantiations like `$shape = new $class_name( $this->images )`
12
 */
13
class Static_Const extends PersistentListItem implements Depends_On {
14
	public $path;
15
	public $line;
16
	public $class_name;
17
	public $const_name;
18
19
	public function __construct( $path, $line, $class_name, $const_name ) {
20
		$this->path = $path;
21
		$this->line = $line;
22
		$this->class_name = $class_name;
23
		$this->const_name = $const_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->const_name
33
		);
34
	}
35
36
	function type() {
37
		return 'class_const';
38
	}
39
40
	function display_name() {
41
		return $this->class_name . '::' . $this->const_name;
42
	}
43
44
	function depends_on( $declaration ) {
45
		return $declaration instanceof Class_Const
46
			&& $this->class_name === $declaration->class_name
47
			&& $this->const_name === $declaration->const_name;
48
	}
49
}