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

Class_Method   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A add_param() 0 3 1
A type() 0 3 1
A display_name() 0 4 2
A __construct() 0 7 1
A to_csv_array() 0 11 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 Class_Method extends Declaration {
9
	public $class_name;
10
	public $method_name;
11
	public $params;
12
	public $static;
13
14
	function __construct( $path, $line, $class_name, $method_name, $static ) {
15
		$this->class_name  = $class_name;
16
		$this->method_name = $method_name;
17
		$this->params      = array();
18
		$this->static      = $static;
19
		parent::__construct( $path, $line );
20
	}
21
22
	// TODO: parse "default" into comparable string form?
23
	function add_param( $name, $default, $type, $byRef, $variadic ) {
24
		$this->params[] = (object) compact( 'name', 'default', 'type', 'byRef', 'variadic' );
25
	}
26
27
	function to_csv_array() {
28
		return array(
29
			$this->type(),
30
			$this->path,
31
			$this->line,
32
			$this->class_name,
33
			$this->method_name,
34
			$this->static,
35
			json_encode( $this->params ),
36
		);
37
	}
38
39
	function type() {
40
		return 'method';
41
	}
42
43
	function display_name() {
44
		$sep = $this->static ? '::' : '->';
45
		return $this->class_name . $sep . $this->method_name . '(' . $this->get_params_as_string() . ')';
46
	}
47
}
48