Code Duplication    Length = 34-34 lines in 2 locations

packages/analyzer/src/Differences/Class_Method_Moved.php 1 location

@@ 9-42 (lines=34) @@
6
use Automattic\Jetpack\Analyzer\Invocations\Static_Call;
7
use Automattic\Jetpack\Analyzer\Warnings\Warning; // TODO - subclasses?
8
9
class Class_Method_Moved extends PersistentListItem implements Invocation_Warner {
10
	public $old_declaration;
11
	public $new_declaration;
12
13
	function __construct( $old_declaration, $new_declaration ) {
14
		$this->old_declaration = $old_declaration;
15
		$this->new_declaration = $new_declaration;
16
	}
17
18
	function to_csv_array() {
19
		return array(
20
			$this->type(),
21
			$this->old_declaration->path,
22
			$this->old_declaration->line,
23
			$this->old_declaration->display_name(),
24
		);
25
	}
26
27
	public function type() {
28
		return 'method_moved';
29
	}
30
31
	public function display_name() {
32
		return $this->old_declaration->display_name();
33
	}
34
35
	public function find_invocation_warnings( $invocation, $warnings ) {
36
		if ( $invocation->depends_on( $this->old_declaration ) ) {
37
			$warnings->add(
38
				new Warning( $this->type(), $invocation->path, $invocation->line, 'Class static method ' . $this->old_declaration->display_name() . ' was moved from ' . $this->old_declaration->path . ' to ' . $this->new_declaration->path, $this->old_declaration )
39
			);
40
		}
41
	}
42
}
43

packages/analyzer/src/Differences/Function_Moved.php 1 location

@@ 9-42 (lines=34) @@
6
use Automattic\Jetpack\Analyzer\Invocations\Function_Call;
7
use Automattic\Jetpack\Analyzer\Warnings\Warning; // TODO - subclasses?
8
9
class Function_Moved extends PersistentListItem implements Invocation_Warner {
10
	public $old_declaration;
11
	public $new_declaration;
12
13
	function __construct( $old_declaration, $new_declaration ) {
14
		$this->old_declaration = $old_declaration;
15
		$this->new_declaration = $new_declaration;
16
	}
17
18
	function to_csv_array() {
19
		return array(
20
			$this->type(),
21
			$this->old_declaration->path,
22
			$this->old_declaration->line,
23
			$this->old_declaration->display_name(),
24
		);
25
	}
26
27
	public function type() {
28
		return 'function_moved';
29
	}
30
31
	public function display_name() {
32
		return $this->old_declaration->display_name();
33
	}
34
35
	public function find_invocation_warnings( $invocation, $warnings ) {
36
		if ( $invocation->depends_on( $this->old_declaration ) ) {
37
			$warnings->add(
38
				new Warning( $this->type(), $invocation->path, $invocation->line, 'Function ' . $this->old_declaration->display_name() . ' was moved from ' . $this->old_declaration->path . ' to ' . $this->new_declaration->path, $this->old_declaration )
39
			);
40
		}
41
	}
42
}
43