Completed
Push — add/amp-ads-support ( 39a9c8...65ae21 )
by
unknown
15:32 queued 08:17
created

Declaration   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 41
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 1

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A match() 0 4 2
A partial_match() 0 4 1
type() 0 1 ?
display_name() 0 1 ?
A get_params_as_string() 0 14 2
1
<?php
2
3
namespace Automattic\Jetpack\Analyzer\Declarations;
4
5
use Automattic\Jetpack\Analyzer\PersistentList\Item as PersistentListItem;
6
7
abstract class Declaration extends PersistentListItem {
8
	public $path;
9
	public $line;
10
11
	function __construct( $path, $line ) {
12
		$this->path = $path;
13
		$this->line = $line;
14
	}
15
16
	function match( $other ) {
17
		return get_class( $other ) === get_class( $this )
18
			&& $other->display_name() === $this->display_name(); // hack
19
	}
20
21
	function partial_match( $other ) {
22
		// TODO
23
		return false;
24
	}
25
26
	// a simple name, like 'method'
27
	abstract function type();
28
29
	// e.g. Jetpack::get_file_url_for_environment()
30
	abstract function display_name();
31
32
	// utility function
33
	protected function get_params_as_string() {
34
		return implode(
35
			',',
36
			array_map(
37
				function( $param ) {
38
					if ( ! empty( $param->default ) ) {
39
						  return '$' . $param->name . '=' . $param->default;
40
					}
41
					return '$' . $param->name;
42
				},
43
				$this->params
0 ignored issues
show
Bug introduced by
The property params does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
44
			)
45
		);
46
	}
47
}
48