Completed
Push — try/code-signature-diff ( 5d24fe...2d24ed )
by
unknown
107:52 queued 99:19
created

Function_::display_name()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Automattic\Jetpack\Analyzer\Declarations;
4
5
/**
6
 * We only log public class methods, whether they are static, and their parameters
7
 */
8
class Function_ extends Declaration {
9
	public $name;
10
	public $params;
11
12
	function __construct( $path, $line, $name ) {
13
		$this->name = $name;
14
		$this->params = array();
15
		parent::__construct( $path, $line );
16
	}
17
18
	// TODO: parse "default" into comparable string form?
19
	function add_param( $name, $default, $type, $byRef, $variadic ) {
20
		$this->params[] = (object) compact( 'name', 'default', 'type', 'byRef', 'variadic' );
21
	}
22
23
	function to_csv_array() {
24
		return array(
25
			$this->type(),
26
			$this->path,
27
			$this->line,
28
			'',
29
			$this->name,
30
			'',
31
			json_encode( $this->params )
32
		);
33
	}
34
35
	function type() {
36
		return 'function';
37
	}
38
39
	function display_name() {
40
		return $this->name . '(' . implode( ', ', array_map( function( $param ) { return '$' . $param->name; }, $this->params ) ) . ')';
41
	}
42
}