Report.php
966 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace Drupal\drupalmoduleupgrader;
/**
* Basic implementation of an analyzer report.
*/
class Report implements ReportInterface {
/**
* @var \Drupal\drupalmoduleupgrader\IssueInterface[]
*/
protected $issues = [];
/**
* {@inheritdoc}
*/
public function addIssue(IssueInterface $issue) {
$id = spl_object_hash($issue);
$this->issues[$id] = $issue;
return $this;
}
/**
* {@inheritdoc}
*/
public function getIssues($tag = NULL) {
// We call array_values() here to reset the keys.
$issues = array_values($this->issues);
if ($tag) {
$issues = array_filter($issues, function(IssueInterface $issue) use ($tag) {
return $issue->hasTag($tag);
});
}
return $issues;
}
public function enumerateTag($tag) {
$enum = array_map(function(IssueInterface $issue) use ($tag) { return $issue->getTag($tag); }, $this->getIssues($tag));
return array_unique($enum);
}
}