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

Function_   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A add_param() 0 3 1
A to_csv_array() 0 11 1
A type() 0 3 1
A display_name() 0 3 1
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