Completed
Push — renovate/glob-7.x ( 697d78...f7fc07 )
by
unknown
18:21 queued 12:01
created

Function_::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 3
dl 0
loc 5
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 $func_name;
10
	public $params;
11
12
	function __construct( $path, $line, $func_name ) {
13
		$this->func_name = $func_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->func_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->func_name . '(' . $this->get_params_as_string() . ')';
41
	}
42
}
43