Code Duplication    Length = 38-38 lines in 2 locations

packages/analyzer/src/Invocations/Static_Call.php 1 location

@@ 13-50 (lines=38) @@
10
 *
11
 * TODO: detect dynamic instantiations like `$shape = new $class_name( $this->images )`
12
 */
13
class Static_Call extends PersistentListItem implements Depends_On {
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
}

packages/analyzer/src/Invocations/Static_Property.php 1 location

@@ 13-50 (lines=38) @@
10
 *
11
 * TODO: detect dynamic instantiations like `$shape = new $class_name( $this->images )`
12
 */
13
class Static_Property extends PersistentListItem implements Depends_On {
14
	public $path;
15
	public $line;
16
	public $class_name;
17
	public $prop_name;
18
19
	public function __construct( $path, $line, $class_name, $prop_name ) {
20
		$this->path = $path;
21
		$this->line = $line;
22
		$this->class_name = $class_name;
23
		$this->prop_name = $prop_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->prop_name
33
		);
34
	}
35
36
	function type() {
37
		return 'static_property';
38
	}
39
40
	function display_name() {
41
		return $this->class_name . '::$' . $this->prop_name;
42
	}
43
44
	function depends_on( $declaration ) {
45
		return $declaration instanceof Class_Property
46
			&& $this->class_name === $declaration->class_name
47
			&& $this->prop_name === $declaration->prop_name
48
			&& $declaration->static;
49
	}
50
}