Completed
Push — add/legacy-files ( 4cc789...bef25d )
by
unknown
157:43 queued 148:20
created

Warnings::summary()   A

Complexity

Conditions 5
Paths 7

Size

Total Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
nc 7
nop 0
dl 0
loc 26
rs 9.1928
c 0
b 0
f 0
1
<?php
2
3
namespace Automattic\Jetpack\Analyzer;
4
5
class Warnings extends PersistentList {
6
	public function generate( $invocations, $differences ) {
7
		/**
8
		 * Scan every invocation to see if it depends on a Difference
9
		 */
10
		foreach( $invocations->get() as $invocation ) {
11
			foreach( $differences->get() as $difference ) {
12
				// $warning = $
13
				$difference->find_invocation_warnings( $invocation, $this );
14
			}
15
		}
16
	}
17
18
	public function summary() {
19
		if ( $this->count() === 0 ) {
20
			return '';
21
		}
22
23
		// assoc array of issues and counts
24
		$summary = array();
25
		foreach( $this->get() as $warning ) {
26
			$unique_issue_key = $warning->unique_issue_key();
27
28
			if ( ! isset( $summary[$unique_issue_key] ) ) {
29
				$summary[$unique_issue_key] = 0;
30
			}
31
32
			$summary[$unique_issue_key] += 1;
33
		}
34
35
		arsort( $summary );
36
37
		$summary_string = '';
38
		foreach( $summary as $issue => $count ) {
39
			$summary_string .= "$issue,$count\n";
40
		}
41
42
		return $summary_string;
43
	}
44
}